1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

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)
This commit is contained in:
Martin Schwenke 2013-06-22 15:44:28 +10:00 committed by Amitay Isaacs
parent 6a52a87028
commit 44e885e98e
3 changed files with 9 additions and 0 deletions

View File

@ -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));

View File

@ -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);

View File

@ -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;