when we are shutting down, we should first shut down the recovery daemon
authorRonnie Sahlberg <sahlberg@ronnie>
Mon, 22 Oct 2007 02:34:08 +0000 (12:34 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Mon, 22 Oct 2007 02:34:08 +0000 (12:34 +1000)
(This used to be ctdb commit 39ade6b329adcd3234124d6a8daaa6181abf739b)

ctdb/include/ctdb_private.h
ctdb/server/ctdb_control.c
ctdb/server/ctdb_recoverd.c

index 4eeb17ec8defd4384c8b09b108b0012504842a9a..7b98683e9ffe22244a2ae1f9e89a540cc88b52d7 100644 (file)
@@ -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);
 
index 959705de6e3c0859b88b75943a97eac78b44e38d..76ac720f1be44ae53c50dfb9597a8e581308a914 100644 (file)
@@ -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");
index b56a1a7a4b396d8fede1368e7ccf3bd5ef87405f..9c5fdda954448d8117856ba3ad5ce69c56106385 100644 (file)
@@ -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);
+}