summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2017-11-17 10:52:57 +1100
committerMartin Schwenke <martins@samba.org>2017-11-21 05:03:16 +0100
commit001ae55011d9c0596f398dc374efc84637f1590c (patch)
treeb0256754e96ab5f2453375efe8d343517c85429b /ctdb
parentfbb5ac8404525a0828504cd744992dfcb7c8e216 (diff)
downloadsamba-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')
-rw-r--r--ctdb/common/sock_daemon.c33
-rwxr-xr-xctdb/tests/cunit/sock_daemon_test_001.sh1
2 files changed, 23 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(
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 <<EOF
test1[PID]: daemon started, pid=PID
test1[PID]: startup failed, ret=1
test1[PID]: listening on $sockpath
+test1[PID]: daemon started, pid=PID
test1[PID]: Shutting down
EOF
unit_test sock_daemon_test "$pidfile" "$sockpath" 1