From: Volker Lendecke Date: Tue, 18 May 2021 06:01:06 +0000 (+0200) Subject: ctdb: Call run_event_recv() in a callback function X-Git-Tag: tevent-0.11.0~865 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9398d4b912387be8cde0c2ca30734eca7d547d19;p=thirdparty%2Fsamba.git ctdb: Call run_event_recv() in a callback function 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 Reviewed-by: Ralph Boehme --- diff --git a/ctdb/tests/src/run_event_test.c b/ctdb/tests/src/run_event_test.c index 3afad557ae9..398ab2a0df0 100644 --- a/ctdb/tests/src/run_event_test.c +++ b/ctdb/tests/src/run_event_test.c @@ -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");