diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h index 388813701f..a69c3173cc 100644 --- a/src/include/private/switch_core_pvt.h +++ b/src/include/private/switch_core_pvt.h @@ -305,6 +305,7 @@ struct switch_runtime { uint32_t port_alloc_flags; char *event_channel_key_separator; uint32_t max_audio_channels; + switch_call_cause_t shutdown_cause; }; extern struct switch_runtime runtime; diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 4757ed1c3a..7217a207a4 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -2292,7 +2292,8 @@ typedef enum { SCSC_SPS_PEAK_FIVEMIN, SCSC_SESSIONS_PEAK, SCSC_SESSIONS_PEAK_FIVEMIN, - SCSC_MDNS_RESOLVE + SCSC_MDNS_RESOLVE, + SCSC_SHUTDOWN_CAUSE } switch_session_ctl_t; typedef enum { diff --git a/src/switch_core.c b/src/switch_core.c index 81b6de762b..c3ddc5124e 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -1857,6 +1857,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc memset(&runtime, 0, sizeof(runtime)); gethostname(runtime.hostname, sizeof(runtime.hostname)); + runtime.shutdown_cause = SWITCH_CAUSE_SYSTEM_SHUTDOWN; runtime.max_db_handles = 50; runtime.db_handle_timeout = 5000000; runtime.event_heartbeat_interval = 20; @@ -3013,6 +3014,9 @@ SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, void * case SCSC_MDNS_RESOLVE: switch_core_media_set_resolveice(!!oldintval); break; + case SCSC_SHUTDOWN_CAUSE: + runtime.shutdown_cause = oldintval; + break; } if (intval) { @@ -3068,7 +3072,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void) switch_set_flag((&runtime), SCF_SHUTTING_DOWN); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "End existing sessions\n"); - switch_core_session_hupall(SWITCH_CAUSE_SYSTEM_SHUTDOWN); + switch_core_session_hupall(runtime.shutdown_cause); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Clean up modules.\n"); switch_loadable_module_shutdown();