diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 4eeb17ec8de..7b98683e9ff 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -365,6 +365,7 @@ struct ctdb_context { struct _trbt_tree_t *server_ids; const char *event_script_dir; const char *default_public_interface; + pid_t recoverd_pid; }; struct ctdb_db_context { @@ -1038,6 +1039,7 @@ int32_t ctdb_control_freeze(struct ctdb_context *ctdb, struct ctdb_req_control * int32_t ctdb_control_thaw(struct ctdb_context *ctdb); int ctdb_start_recoverd(struct ctdb_context *ctdb); +void ctdb_stop_recoverd(struct ctdb_context *ctdb); uint32_t ctdb_get_num_active_nodes(struct ctdb_context *ctdb); diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c index 959705de6e3..76ac720f1be 100644 --- a/ctdb/server/ctdb_control.c +++ b/ctdb/server/ctdb_control.c @@ -232,6 +232,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb, return ctdb->monitoring_mode; case CTDB_CONTROL_SHUTDOWN: + ctdb_stop_recoverd(ctdb); ctdb_release_all_ips(ctdb); ctdb->methods->shutdown(ctdb); ctdb_event_script(ctdb, "shutdown"); diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index b56a1a7a4b3..9c5fdda9544 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -22,6 +22,7 @@ #include "system/filesys.h" #include "system/time.h" #include "system/network.h" +#include "system/wait.h" #include "popt.h" #include "cmdline.h" #include "../include/ctdb.h" @@ -1950,18 +1951,17 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb) { int ret; int fd[2]; - pid_t child; if (pipe(fd) != 0) { return -1; } - child = fork(); - if (child == -1) { + ctdb->recoverd_pid = fork(); + if (ctdb->recoverd_pid == -1) { return -1; } - if (child != 0) { + if (ctdb->recoverd_pid != 0) { close(fd[0]); return 0; } @@ -1995,3 +1995,16 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb) DEBUG(0,("ERROR: ctdb_recoverd finished!?\n")); return -1; } + +/* + shutdown the recovery daemon + */ +void ctdb_stop_recoverd(struct ctdb_context *ctdb) +{ + if (ctdb->recoverd_pid == 0) { + return; + } + + DEBUG(0,("Shutting down recovery daemon\n")); + kill(ctdb->recoverd_pid, SIGTERM); +}