From: Amitay Isaacs Date: Tue, 6 Mar 2018 03:28:43 +0000 (+1100) Subject: ctdb-tools: Wait for ctdb daemon to go away in shutdown X-Git-Tag: talloc-2.1.12~235 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=35cc786d1083cba944b91775982c6a403fe8be20;p=thirdparty%2Fsamba.git ctdb-tools: Wait for ctdb daemon to go away in shutdown This can only be done on the local node. For remote node, exit as soon as the control returns. Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke --- diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index 2cb46b057f0..8535c784c93 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -2833,15 +2833,29 @@ static int control_unban(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, } +static void wait_for_shutdown(void *private_data) +{ + bool *done = (bool *)private_data; + + *done = true; +} + static int control_shutdown(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, int argc, const char **argv) { int ret; + bool done = false; if (argc != 0) { usage("shutdown"); } + if (ctdb->pnn == ctdb->cmd_pnn) { + ctdb_client_set_disconnect_callback(ctdb->client, + wait_for_shutdown, + &done); + } + ret = ctdb_ctrl_shutdown(mem_ctx, ctdb->ev, ctdb->client, ctdb->cmd_pnn, TIMEOUT()); if (ret != 0) { @@ -2849,6 +2863,10 @@ static int control_shutdown(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, return ret; } + if (ctdb->pnn == ctdb->cmd_pnn) { + ctdb_client_wait(ctdb->ev, &done); + } + return 0; }