From 3be64cbf6286abcff529f30b1bc854895e250ba0 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 20 Jun 2011 10:07:01 -0500 Subject: [PATCH] FS-3354 --resolve --- src/mod/endpoints/mod_sofia/mod_sofia.c | 11 ++++++----- src/mod/endpoints/mod_sofia/sofia.c | 26 +++++++++---------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 979d80037d..fb2e161b16 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -5233,11 +5233,6 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown) switch_console_set_complete("del sofia"); switch_mutex_lock(mod_sofia_globals.mutex); - - for (i = 0; i < mod_sofia_globals.msg_queue_len; i++) { - switch_queue_push(mod_sofia_globals.msg_queue[i], NULL); - } - if (mod_sofia_globals.running == 1) { mod_sofia_globals.running = 0; } @@ -5259,11 +5254,17 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown) } } + + for (i = 0; i < mod_sofia_globals.msg_queue_len; i++) { + switch_queue_push(mod_sofia_globals.msg_queue[i], NULL); + } + for (i = 0; i < mod_sofia_globals.msg_queue_len; i++) { switch_status_t st; switch_thread_join(&st, mod_sofia_globals.msg_queue_thread[i]); } + //switch_yield(1000000); su_deinit(); diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 026c3c9ba1..17cb9f7183 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -949,8 +949,9 @@ static void our_sofia_event_callback(nua_event_t event, switch_channel_set_flag(channel, CF_MEDIA_ACK); break; case nua_r_shutdown: - if (status >= 200) + if (status >= 200) { su_root_break(profile->s_root); + } break; case nua_r_message: sofia_handle_sip_r_message(status, profile, nh, sip); @@ -1127,24 +1128,10 @@ void *SWITCH_THREAD_FUNC sofia_msg_thread_run(switch_thread_t *thread, void *obj switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MSG Thread Started\n"); - while (mod_sofia_globals.running == 1) { - - if (switch_queue_pop(q, &pop) == SWITCH_STATUS_SUCCESS) { - sofia_dispatch_event_t *de = (sofia_dispatch_event_t *) pop; - if (!pop) { - break; - } - - sofia_process_dispatch_event(&de); - } - } - - while (switch_queue_trypop(q, &pop) == SWITCH_STATUS_SUCCESS && pop) { + while(switch_queue_pop(q, &pop) == SWITCH_STATUS_SUCCESS && pop) { sofia_dispatch_event_t *de = (sofia_dispatch_event_t *) pop; - nua_handle_unref(de->nh); - nua_destroy_event(de->event); - free(de); + sofia_process_dispatch_event(&de); } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MSG Thread Ended\n"); @@ -1193,6 +1180,11 @@ static void sofia_queue_message(sofia_dispatch_event_t *de) { int idx = 0; + if (mod_sofia_globals.running == 0) { + sofia_process_dispatch_event(&de); + return; + } + again: switch_mutex_lock(mod_sofia_globals.mutex);