diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 23f11ac765..8e40776b51 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -219,9 +219,10 @@ SWITCH_DECLARE(uint32_t) switch_core_session_limit(uint32_t new_limit); /*! \brief Destroy the core + \param vg nonzero to skip core uninitilize for memory debugging \note to be called at application shutdown */ -SWITCH_DECLARE(switch_status_t) switch_core_destroy(void); +SWITCH_DECLARE(switch_status_t) switch_core_destroy(int vg); ///\} diff --git a/src/switch.c b/src/switch.c index 601aa85b25..604add77a9 100644 --- a/src/switch.c +++ b/src/switch.c @@ -195,6 +195,7 @@ int main(int argc, char *argv[]) char pid_path[256] = ""; // full path to the pid file const char *err = NULL; // error value for return from freeswitch initialization int bg = 0; // TRUE if we are running in background mode + int vg = 0; // TRUE if we are running in vg mode FILE *f; // file handle to the pid file pid_t pid = 0; // int x; // @@ -265,6 +266,10 @@ int main(int argc, char *argv[]) if (argv[x] && !strcmp(argv[x], "-nc")) { bg++; } + + if (argv[x] && !strcmp(argv[x], "-vg")) { + vg++; + } } if (die) { @@ -302,5 +307,5 @@ int main(int argc, char *argv[]) switch_core_runtime_loop(bg); - return switch_core_destroy(); + return switch_core_destroy(vg); } diff --git a/src/switch_core.c b/src/switch_core.c index f65377a2dc..a06293ce04 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -4070,7 +4070,7 @@ SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, uint32 return 0; } -SWITCH_DECLARE(switch_status_t) switch_core_destroy(void) +SWITCH_DECLARE(switch_status_t) switch_core_destroy(int vg) { switch_event_t *event; if (switch_event_create(&event, SWITCH_EVENT_SHUTDOWN) == SWITCH_STATUS_SUCCESS) { @@ -4097,7 +4097,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void) switch_core_db_close(runtime.db); switch_core_db_close(runtime.event_db); switch_xml_destroy(); - + if (vg) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Full destruction of the core disabled for memory debugging purposes.\n"); + } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Finalizing Shutdown.\n"); switch_log_shutdown(); @@ -4108,7 +4110,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void) if (runtime.memory_pool) { apr_pool_destroy(runtime.memory_pool); - apr_terminate(); + if (!vg) { + apr_terminate(); + } } #ifdef WIN32