diff options
author | Volker Lendecke <vl@samba.org> | 2021-05-18 08:01:06 +0200 |
---|---|---|
committer | Ralph Boehme <slow@samba.org> | 2021-05-18 10:42:32 +0000 |
commit | 9398d4b912387be8cde0c2ca30734eca7d547d19 (patch) | |
tree | 0de8b9ceac19e6fc9db2e5460d07d62f0d7fcd71 /ctdb | |
parent | f188c9d732e4b9b3d37c4cb09608aba747845997 (diff) | |
download | samba-9398d4b912387be8cde0c2ca30734eca7d547d19.tar.gz |
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 <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/tests/src/run_event_test.c | 24 |
1 files changed, 16 insertions, 8 deletions
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"); |