diff options
author | Amitay Isaacs <amitay@gmail.com> | 2017-11-17 10:52:57 +1100 |
---|---|---|
committer | Martin Schwenke <martins@samba.org> | 2017-11-21 05:03:16 +0100 |
commit | 001ae55011d9c0596f398dc374efc84637f1590c (patch) | |
tree | b0256754e96ab5f2453375efe8d343517c85429b /ctdb/common | |
parent | fbb5ac8404525a0828504cd744992dfcb7c8e216 (diff) | |
download | samba-001ae55011d9c0596f398dc374efc84637f1590c.tar.gz |
ctdb-common: Start wait computation only after successful startup
This orders the startup events in sock_daemon code.
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb/common')
-rw-r--r-- | ctdb/common/sock_daemon.c | 33 |
1 files changed, 22 insertions, 11 deletions
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( |