]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
clean shutdown in ctdb - release all our IPs
authorAndrew Tridgell <tridge@samba.org>
Tue, 29 May 2007 03:33:59 +0000 (13:33 +1000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 29 May 2007 03:33:59 +0000 (13:33 +1000)
(This used to be ctdb commit 2f196cb6a86eb85205d7de1c4cadd4e1e701c06f)

ctdb/common/ctdb_control.c
ctdb/include/ctdb_private.h
ctdb/takeover/ctdb_takeover.c
ctdb/tools/events

index a1885c1078a46da77410ee093ece0162c555a0f5..1d1dadd0e08bb020708da665ab6cfed0de8d636e 100644 (file)
@@ -250,7 +250,10 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
                return ctdb->monitoring_mode;
 
        case CTDB_CONTROL_SHUTDOWN:
-               exit(10);
+               ctdb_release_all_ips(ctdb);
+               ctdb_event_script(ctdb, "shutdown");
+               DEBUG(0,("shutting down\n"));
+               exit(0);
 
        case CTDB_CONTROL_MAX_RSN: 
                CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));
index f5d93b5301e5141ee2e6cab6bfb3eea9d229376c..b7539cbbae4ec8698492c19fb35d802454126406 100644 (file)
@@ -946,5 +946,6 @@ int32_t ctdb_control_startup(struct ctdb_context *ctdb, uint32_t vnn);
 
 void ctdb_takeover_client_destructor_hook(struct ctdb_client *client);
 int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...);
+void ctdb_release_all_ips(struct ctdb_context *ctdb);
 
 #endif
index 02e2825e6bb607e2570811f2764b5479c99dae67..55f69d5e9462426170cd7653e0dccf9123de5423 100644 (file)
@@ -526,3 +526,26 @@ void ctdb_takeover_client_destructor_hook(struct ctdb_client *client)
                talloc_free(tcp);
        }
 }
+
+
+/*
+  release all IPs on shutdown
+ */
+void ctdb_release_all_ips(struct ctdb_context *ctdb)
+{
+       int i;
+
+       if (!ctdb->takeover.enabled) {
+               return;
+       }
+
+       for (i=0;i<ctdb->num_nodes;i++) {
+               struct ctdb_node *node = ctdb->nodes[i];
+               if (ctdb_sys_have_ip(node->public_address)) {
+                       ctdb_event_script(ctdb, "releaseip %s %s %u",
+                                         ctdb->takeover.interface, 
+                                         node->public_address,
+                                         node->public_netmask_bits);
+               }
+       }
+}
index 3de92d0f3c7de6ceda4a47addd8b8e9faeffb279..ce86ca3a71a5d1e7e5214a17181e0757e68f9cd9 100755 (executable)
@@ -30,6 +30,7 @@ case $cmd in
        ;;
 
      recovered)
+     shutdown)
         # restart any services as necessary, like NFS
        exit 0
        ;;