]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-3354 --resolve
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 20 Jun 2011 15:07:01 +0000 (10:07 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 20 Jun 2011 15:07:01 +0000 (10:07 -0500)
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia.c

index 979d80037d1baf079605c6881ba274f8cefe5bd9..fb2e161b16ebdba876f9c275e877c712e2d8f4a6 100644 (file)
@@ -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();
 
index 026c3c9ba158d0fcdb8aa9f55b85aae6fe00e32e..17cb9f718308c7af5540b8584807305823b5623c 100644 (file)
@@ -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);