提交 748f0194 authored 作者: Anthony Minessale's avatar Anthony Minessale

tweak shutdown process

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2299 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 a675393b
...@@ -220,12 +220,9 @@ int main(int argc, char *argv[]) ...@@ -220,12 +220,9 @@ int main(int argc, char *argv[])
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "End existing sessions\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "End existing sessions\n");
switch_core_session_hupall(); switch_core_session_hupall();
switch_yield(10000);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Clean up modules.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Clean up modules.\n");
switch_loadable_module_shutdown(); switch_loadable_module_shutdown();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Tearing down environment.\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Exiting Now.\n");
switch_core_destroy(); switch_core_destroy();
return 0; return 0;
} }
...@@ -3116,10 +3116,11 @@ SWITCH_DECLARE(switch_time_t) switch_core_uptime(void) ...@@ -3116,10 +3116,11 @@ SWITCH_DECLARE(switch_time_t) switch_core_uptime(void)
SWITCH_DECLARE(switch_status_t) switch_core_destroy(void) SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
{ {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Closing Event Engine.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Closing Event Engine.\n");
switch_event_shutdown(); switch_event_shutdown();
switch_queue_push(runtime.sql_queue, NULL); switch_queue_push(runtime.sql_queue, NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Waiting for unfinished SQL transactions\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Waiting for unfinished SQL transactions\n");
while (switch_queue_size(runtime.sql_queue) > 0) { while (switch_queue_size(runtime.sql_queue) > 0) {
...@@ -3128,10 +3129,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void) ...@@ -3128,10 +3129,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
switch_core_db_close(runtime.db); switch_core_db_close(runtime.db);
switch_core_db_close(runtime.event_db); switch_core_db_close(runtime.event_db);
switch_xml_destroy(); switch_xml_destroy();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Finalizing Shutdown.\n");
switch_log_shutdown(); switch_log_shutdown();
switch_yield(10000);
if (runtime.memory_pool) { if (runtime.memory_pool) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Unallocating memory pool.\n");
apr_pool_destroy(runtime.memory_pool); apr_pool_destroy(runtime.memory_pool);
apr_terminate(); apr_terminate();
} }
......
...@@ -118,7 +118,7 @@ static void *SWITCH_THREAD_FUNC log_thread(switch_thread_t *thread, void *obj) ...@@ -118,7 +118,7 @@ static void *SWITCH_THREAD_FUNC log_thread(switch_thread_t *thread, void *obj)
assert(obj == NULL || obj != NULL); assert(obj == NULL || obj != NULL);
THREAD_RUNNING = 1; THREAD_RUNNING = 1;
while(LOG_QUEUE) { while(THREAD_RUNNING == 1) {
void *pop = NULL; void *pop = NULL;
switch_log_node_t *node = NULL; switch_log_node_t *node = NULL;
switch_log_binding_t *binding; switch_log_binding_t *binding;
...@@ -128,7 +128,6 @@ static void *SWITCH_THREAD_FUNC log_thread(switch_thread_t *thread, void *obj) ...@@ -128,7 +128,6 @@ static void *SWITCH_THREAD_FUNC log_thread(switch_thread_t *thread, void *obj)
} }
if (!pop) { if (!pop) {
LOG_QUEUE = NULL;
break; break;
} }
...@@ -277,7 +276,11 @@ SWITCH_DECLARE(switch_status_t) switch_log_init(switch_memory_pool_t *pool) ...@@ -277,7 +276,11 @@ SWITCH_DECLARE(switch_status_t) switch_log_init(switch_memory_pool_t *pool)
SWITCH_DECLARE(switch_status_t) switch_log_shutdown(void) SWITCH_DECLARE(switch_status_t) switch_log_shutdown(void)
{ {
THREAD_RUNNING = -1;
switch_queue_push(LOG_QUEUE, NULL); switch_queue_push(LOG_QUEUE, NULL);
while (THREAD_RUNNING) {
switch_yield(1000);
}
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论