summaryrefslogtreecommitdiff
path: root/ctdb/common
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2017-11-17 12:38:18 +1100
committerMartin Schwenke <martins@samba.org>2017-11-21 05:03:17 +0100
commit41d888afbecfca6e4ea3c6c86c05101bd5e5b5c4 (patch)
treeeb8b8cec81bd393604568e439853b6cbaa523a19 /ctdb/common
parent7558592d15fa4911fa8d2061aa56e2b151f516a2 (diff)
downloadsamba-41d888afbecfca6e4ea3c6c86c05101bd5e5b5c4.tar.gz
ctdb-common: Add async version of reconfigure in sock_daemon
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.c34
-rw-r--r--ctdb/common/sock_daemon.h8
2 files changed, 42 insertions, 0 deletions
diff --git a/ctdb/common/sock_daemon.c b/ctdb/common/sock_daemon.c
index 6b05e2462f9..ce6f9230a6d 100644
--- a/ctdb/common/sock_daemon.c
+++ b/ctdb/common/sock_daemon.c
@@ -533,6 +533,7 @@ static void sock_daemon_run_signal_handler(struct tevent_context *ev,
int signum, int count, void *siginfo,
void *private_data);
static void sock_daemon_run_reconfigure(struct tevent_req *req);
+static void sock_daemon_run_reconfigure_done(struct tevent_req *subreq);
static void sock_daemon_run_shutdown(struct tevent_req *req);
static bool sock_daemon_run_socket_listen(struct tevent_req *req);
static void sock_daemon_run_socket_fail(struct tevent_req *subreq);
@@ -717,10 +718,23 @@ static void sock_daemon_run_signal_handler(struct tevent_context *ev,
static void sock_daemon_run_reconfigure(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->reconfigure_send != NULL &&
+ sockd->funcs->reconfigure_recv != NULL) {
+ subreq = sockd->funcs->reconfigure_send(state, state->ev,
+ sockd->private_data);
+ if (tevent_req_nomem(subreq, req)) {
+ return;
+ }
+ tevent_req_set_callback(subreq,
+ sock_daemon_run_reconfigure_done, req);
+ return;
+ }
+
if (sockd->funcs != NULL && sockd->funcs->reconfigure != NULL) {
int ret;
@@ -734,6 +748,26 @@ static void sock_daemon_run_reconfigure(struct tevent_req *req)
}
}
+static void sock_daemon_run_reconfigure_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct sock_daemon_run_state *state = tevent_req_data(
+ req, struct sock_daemon_run_state);
+ struct sock_daemon_context *sockd = state->sockd;
+ int ret;
+ bool status;
+
+ status = sockd->funcs->reconfigure_recv(subreq, &ret);
+ TALLOC_FREE(subreq);
+ if (! status) {
+ D_ERR("reconfigure failed, ret=%d\n", ret);
+ return;
+ }
+
+ D_NOTICE("reconfigure completed successfully\n");
+}
+
static void sock_daemon_run_shutdown(struct tevent_req *req)
{
struct sock_daemon_run_state *state = tevent_req_data(
diff --git a/ctdb/common/sock_daemon.h b/ctdb/common/sock_daemon.h
index 7f19b32dcd4..2cc94c6bf5d 100644
--- a/ctdb/common/sock_daemon.h
+++ b/ctdb/common/sock_daemon.h
@@ -58,6 +58,8 @@ struct sock_client_context;
* reconfigure() should return 0 for success, non-zero value on failure
* On failure, sock_daemon_run() will continue to run.
*
+ * reconfigure_send()/reconfigure_recv() is the async version of reconfigure()
+ *
* shutdown() is called when process receives SIGINT or SIGTERM or
* when wait computation has finished
*
@@ -76,6 +78,12 @@ struct sock_daemon_funcs {
bool (*startup_recv)(struct tevent_req *req, int *perr);
int (*reconfigure)(void *private_data);
+
+ struct tevent_req * (*reconfigure_send)(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ void *private_data);
+ bool (*reconfigure_recv)(struct tevent_req *req, int *perr);
+
void (*shutdown)(void *private_data);
struct tevent_req * (*wait_send)(TALLOC_CTX *mem_ctx,