]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb: Call run_event_recv() in a callback function
authorVolker Lendecke <vl@samba.org>
Tue, 18 May 2021 06:01:06 +0000 (08:01 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 18 May 2021 10:42:32 +0000 (10:42 +0000)
Triggers a different code path in run_event_* and aligns it more what
the ctdb eventd really does.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14475
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
ctdb/tests/src/run_event_test.c

index 3afad557ae9d57b55d66606f1f1c7ba9bd3f5953..398ab2a0df0f4f10006a5ee6d4cb20ba39053e3f 100644 (file)
@@ -52,6 +52,19 @@ static char *compact_args(const char **argv, int argc, int from)
        return arg_str;
 }
 
+static void run_done(struct tevent_req *req)
+{
+       struct run_event_script_list **script_list =
+               tevent_req_callback_data_void(req);
+       bool status;
+       int ret;
+
+       status = run_event_recv(req, &ret, NULL, script_list);
+       if (!status) {
+               fprintf(stderr, "run_event_recv() failed, ret=%d\n", ret);
+       }
+}
+
 static void do_run(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
                   struct run_event_context *run_ctx,
                   int argc, const char **argv)
@@ -61,8 +74,7 @@ static void do_run(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
        struct run_event_script_list *script_list = NULL;
        char *arg_str;
        unsigned int i;
-       int ret, t;
-       bool status;
+       int t;
 
        if (argc < 5) {
                usage(argv[0]);
@@ -90,13 +102,9 @@ static void do_run(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
                return;
        }
 
-       tevent_req_poll(req, ev);
+       tevent_req_set_callback(req, run_done, &script_list);
 
-       status = run_event_recv(req, &ret, mem_ctx, &script_list);
-       if (! status) {
-               fprintf(stderr, "run_event_recv() failed, ret=%d\n", ret);
-               return;
-       }
+       tevent_req_poll(req, ev);
 
        if (script_list == NULL || script_list->num_scripts == 0) {
                printf("No event scripts found\n");