summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2013-06-22 15:44:28 +1000
committerAmitay Isaacs <amitay@gmail.com>2013-06-22 15:51:16 +1000
commit44e885e98e06e57cd4643fa884a4f780ca68cdba (patch)
tree4b7b3a795a26014f4879a63f82ba93fc138fc6eb
parent6a52a87028c653edbcede161e96857ff37d802ee (diff)
downloadsamba-44e885e98e06e57cd4643fa884a4f780ca68cdba.tar.gz
samba-44e885e98e06e57cd4643fa884a4f780ca68cdba.tar.xz
samba-44e885e98e06e57cd4643fa884a4f780ca68cdba.zip
ctdbd: Fix panic on overlapping shutdowns
The runstate can't be set to SHUTDOWN twice, so the current naive code causes a panic on the 2nd shutdown. This regression was introduced in commit 8076773a9924dcf8aff16f7d96b2b9ac383ecc28. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit f1b7ca8dc3f34a59c7b3e55748f974ac9ed8f458)
-rw-r--r--ctdb/server/ctdb_control.c2
-rw-r--r--ctdb/server/ctdb_daemon.c5
-rw-r--r--ctdb/server/ctdb_monitor.c2
3 files changed, 9 insertions, 0 deletions
diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c
index 0f2e600b946..a8771f31766 100644
--- a/ctdb/server/ctdb_control.c
+++ b/ctdb/server/ctdb_control.c
@@ -333,6 +333,8 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
case CTDB_CONTROL_SHUTDOWN:
DEBUG(DEBUG_NOTICE,("Received SHUTDOWN command.\n"));
ctdb_shutdown_sequence(ctdb, 0);
+ /* In case above returns due to duplicate shutdown */
+ return 0;
case CTDB_CONTROL_TAKEOVER_IPv4:
CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_public_ipv4));
diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
index 3c813ab9b8c..478962d6246 100644
--- a/ctdb/server/ctdb_daemon.c
+++ b/ctdb/server/ctdb_daemon.c
@@ -1728,6 +1728,11 @@ int32_t ctdb_control_process_exists(struct ctdb_context *ctdb, pid_t pid)
void ctdb_shutdown_sequence(struct ctdb_context *ctdb, int exit_code)
{
+ if (ctdb->runstate == CTDB_RUNSTATE_SHUTDOWN) {
+ DEBUG(DEBUG_NOTICE,("Already shutting down so will not proceed.\n"));
+ return;
+ }
+
DEBUG(DEBUG_NOTICE,("Shutdown sequence commencing.\n"));
ctdb_set_runstate(ctdb, CTDB_RUNSTATE_SHUTDOWN);
ctdb_stop_recoverd(ctdb);
diff --git a/ctdb/server/ctdb_monitor.c b/ctdb/server/ctdb_monitor.c
index 70ca47d6416..106a44f7d27 100644
--- a/ctdb/server/ctdb_monitor.c
+++ b/ctdb/server/ctdb_monitor.c
@@ -295,6 +295,8 @@ static void ctdb_wait_until_recovered(struct event_context *ev, struct timed_eve
"ctdb_recheck_persistent_health() failed (%llu times) - prepare shutdown\n",
(unsigned long long)ctdb->db_persistent_check_errors));
ctdb_shutdown_sequence(ctdb, 11);
+ /* In case above returns due to duplicate shutdown */
+ return;
}
ctdb->db_persistent_check_errors = 0;