diff --git a/src/switch_core.c b/src/switch_core.c index 2b689067a0..9d23f5b5a5 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -398,6 +398,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(const char *console, const char switch_uuid_t uuid; memset(&runtime, 0, sizeof(runtime)); + runtime.no_new_sessions = 1; + /* INIT APR and Create the pool context */ if (apr_initialize() != SWITCH_STATUS_SUCCESS) { *err = "FATAL ERROR! Could not initilize APR\n"; @@ -577,6 +579,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(const char *console "\nFreeSWITCH Version %s Started.\nCrash Protection [%s]\nMax Sessions[%u]\n\n", SWITCH_VERSION_FULL, runtime.crash_prot ? "Enabled" : "Disabled", switch_core_session_limit(0)); + + runtime.no_new_sessions = 0; + return SWITCH_STATUS_SUCCESS; } diff --git a/src/switch_core_session.c b/src/switch_core_session.c index e8043fede8..ffc9b2e4ed 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -767,7 +767,10 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request(const switch switch_uuid_t uuid; uint32_t count = 0; - assert(endpoint_interface != NULL); + if (!switch_core_ready() || endpoint_interface == NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "The system cannot create any sessions at this time.\n"); + return NULL; + } switch_mutex_lock(session_manager.session_table_mutex); count = session_manager.session_count; @@ -778,11 +781,6 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request(const switch return NULL; } - if (!switch_core_ready()) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read my lips: no new sessions!\n"); - return NULL; - } - if (pool && *pool) { usepool = *pool; *pool = NULL;