mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
ctdbd: Refactor shutdown sequence
Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit b32fd04bfbf33062d45365b37a7247e272a76ceb)
This commit is contained in:
parent
01d879806b
commit
6a52a87028
@ -450,6 +450,8 @@ const char *runstate_to_string(enum ctdb_runstate runstate);
|
||||
enum ctdb_runstate runstate_from_string(const char *label);
|
||||
void ctdb_set_runstate(struct ctdb_context *ctdb, enum ctdb_runstate runstate);
|
||||
|
||||
void ctdb_shutdown_sequence(struct ctdb_context *ctdb, int exit_code);
|
||||
|
||||
#define CTDB_MONITORING_ACTIVE 0
|
||||
#define CTDB_MONITORING_DISABLED 1
|
||||
|
||||
|
@ -331,17 +331,8 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
|
||||
return 0;
|
||||
|
||||
case CTDB_CONTROL_SHUTDOWN:
|
||||
DEBUG(DEBUG_NOTICE,("Received SHUTDOWN command. Stopping CTDB daemon.\n"));
|
||||
ctdb_set_runstate(ctdb, CTDB_RUNSTATE_SHUTDOWN);
|
||||
ctdb_stop_recoverd(ctdb);
|
||||
ctdb_stop_keepalive(ctdb);
|
||||
ctdb_stop_monitoring(ctdb);
|
||||
ctdb_release_all_ips(ctdb);
|
||||
ctdb_event_script(ctdb, CTDB_EVENT_SHUTDOWN);
|
||||
if (ctdb->methods != NULL) {
|
||||
ctdb->methods->shutdown(ctdb);
|
||||
}
|
||||
exit(0);
|
||||
DEBUG(DEBUG_NOTICE,("Received SHUTDOWN command.\n"));
|
||||
ctdb_shutdown_sequence(ctdb, 0);
|
||||
|
||||
case CTDB_CONTROL_TAKEOVER_IPv4:
|
||||
CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_public_ipv4));
|
||||
|
@ -1725,3 +1725,20 @@ int32_t ctdb_control_process_exists(struct ctdb_context *ctdb, pid_t pid)
|
||||
|
||||
return kill(pid, 0);
|
||||
}
|
||||
|
||||
void ctdb_shutdown_sequence(struct ctdb_context *ctdb, int exit_code)
|
||||
{
|
||||
DEBUG(DEBUG_NOTICE,("Shutdown sequence commencing.\n"));
|
||||
ctdb_set_runstate(ctdb, CTDB_RUNSTATE_SHUTDOWN);
|
||||
ctdb_stop_recoverd(ctdb);
|
||||
ctdb_stop_keepalive(ctdb);
|
||||
ctdb_stop_monitoring(ctdb);
|
||||
ctdb_release_all_ips(ctdb);
|
||||
ctdb_event_script(ctdb, CTDB_EVENT_SHUTDOWN);
|
||||
if (ctdb->methods != NULL) {
|
||||
ctdb->methods->shutdown(ctdb);
|
||||
}
|
||||
|
||||
DEBUG(DEBUG_NOTICE,("Shutdown sequence complete, exiting.\n"));
|
||||
exit(exit_code);
|
||||
}
|
||||
|
@ -294,16 +294,7 @@ static void ctdb_wait_until_recovered(struct event_context *ev, struct timed_eve
|
||||
DEBUG(DEBUG_ALERT,(__location__
|
||||
"ctdb_recheck_persistent_health() failed (%llu times) - prepare shutdown\n",
|
||||
(unsigned long long)ctdb->db_persistent_check_errors));
|
||||
ctdb_stop_recoverd(ctdb);
|
||||
ctdb_stop_keepalive(ctdb);
|
||||
ctdb_stop_monitoring(ctdb);
|
||||
ctdb_release_all_ips(ctdb);
|
||||
if (ctdb->methods != NULL) {
|
||||
ctdb->methods->shutdown(ctdb);
|
||||
}
|
||||
ctdb_event_script(ctdb, CTDB_EVENT_SHUTDOWN);
|
||||
DEBUG(DEBUG_ALERT,("ctdb_recheck_persistent_health() failed - Stopping CTDB daemon\n"));
|
||||
exit(11);
|
||||
ctdb_shutdown_sequence(ctdb, 11);
|
||||
}
|
||||
ctdb->db_persistent_check_errors = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user