From: Amitay Isaacs Date: Thu, 16 Nov 2017 23:52:57 +0000 (+1100) Subject: ctdb-common: Start wait computation only after successful startup X-Git-Tag: talloc-2.1.11~431 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=001ae55011d9c0596f398dc374efc84637f1590c;p=thirdparty%2Fsamba.git ctdb-common: Start wait computation only after successful startup This orders the startup events in sock_daemon code. Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke --- diff --git a/ctdb/common/sock_daemon.c b/ctdb/common/sock_daemon.c index bb241e0ebd8..8ceb7c96bda 100644 --- a/ctdb/common/sock_daemon.c +++ b/ctdb/common/sock_daemon.c @@ -526,6 +526,7 @@ static void sock_daemon_run_reconfigure(struct tevent_req *req); static void sock_daemon_run_shutdown(struct tevent_req *req); static void sock_daemon_run_socket_fail(struct tevent_req *subreq); static void sock_daemon_run_watch_pid(struct tevent_req *subreq); +static void sock_daemon_run_wait(struct tevent_req *req); static void sock_daemon_run_wait_done(struct tevent_req *subreq); struct tevent_req *sock_daemon_run_send(TALLOC_CTX *mem_ctx, @@ -615,17 +616,6 @@ struct tevent_req *sock_daemon_run_send(TALLOC_CTX *mem_ctx, req); } - if (sockd->funcs != NULL && sockd->funcs->wait_send != NULL && - sockd->funcs->wait_recv != NULL) { - subreq = sockd->funcs->wait_send(state, ev, - sockd->private_data); - if (tevent_req_nomem(subreq, req)) { - return tevent_req_post(req, ev); - } - tevent_req_set_callback(subreq, sock_daemon_run_wait_done, - req); - } - return req; } @@ -659,6 +649,8 @@ static void sock_daemon_run_started(struct tevent_req *subreq) D_NOTICE("startup completed successfully\n"); } + + sock_daemon_run_wait(req); } static void sock_daemon_run_signal_handler(struct tevent_context *ev, @@ -776,6 +768,25 @@ static void sock_daemon_run_watch_pid(struct tevent_req *subreq) tevent_req_set_callback(subreq, sock_daemon_run_watch_pid, req); } +static void sock_daemon_run_wait(struct tevent_req *req) +{ + struct tevent_req *subreq; + struct sock_daemon_run_state *state = tevent_req_data( + req, struct sock_daemon_run_state); + struct sock_daemon_context *sockd = state->sockd; + + if (sockd->funcs != NULL && sockd->funcs->wait_send != NULL && + sockd->funcs->wait_recv != NULL) { + subreq = sockd->funcs->wait_send(state, state->ev, + sockd->private_data); + if (tevent_req_nomem(subreq, req)) { + return; + } + tevent_req_set_callback(subreq, sock_daemon_run_wait_done, + req); + } +} + static void sock_daemon_run_wait_done(struct tevent_req *subreq) { struct tevent_req *req = tevent_req_callback_data( diff --git a/ctdb/tests/cunit/sock_daemon_test_001.sh b/ctdb/tests/cunit/sock_daemon_test_001.sh index cbb5a7e292a..0561863e256 100755 --- a/ctdb/tests/cunit/sock_daemon_test_001.sh +++ b/ctdb/tests/cunit/sock_daemon_test_001.sh @@ -26,6 +26,7 @@ ok <