]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_sofia] sofia_process_dispatch_event() should unref all handles via sofia stack
authorAndrey Volk <andywolk@gmail.com>
Mon, 7 Jun 2021 17:46:58 +0000 (20:46 +0300)
committerAndrey Volk <andywolk@gmail.com>
Mon, 14 Jun 2021 16:46:28 +0000 (19:46 +0300)
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c

index ce9d520ba83bd4116f0b1dc8084f79481feb867d..79a3c06795a942e98912fa97992ae6eb69f9f496 100644 (file)
@@ -1343,7 +1343,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                        de->session = session;
                }
 
-               sofia_process_dispatch_event(&de, SWITCH_FALSE);
+               sofia_process_dispatch_event(&de);
 
 
                switch_mutex_unlock(tech_pvt->sofia_mutex);
index e91d849913bcb71d5ba5a2f7007ba7c3006d07d0..02128bf2fd7294b2370d3f08d8c868f502df0741 100644 (file)
@@ -1253,7 +1253,7 @@ uint32_t sofia_presence_get_cseq(sofia_profile_t *profile);
 void sofia_glue_build_vid_refresh_message(switch_core_session_t *session, const char *pl);
 char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, nua_handle_t *nh, sofia_dispatch_event_t *de, sofia_nat_parse_t *np);
 void sofia_glue_pause_jitterbuffer(switch_core_session_t *session, switch_bool_t on);
-void sofia_process_dispatch_event(sofia_dispatch_event_t **dep, switch_bool_t stack_thread);
+void sofia_process_dispatch_event(sofia_dispatch_event_t **dep);
 void sofia_process_dispatch_event_in_thread(sofia_dispatch_event_t **dep);
 char *sofia_glue_get_host(const char *str, switch_memory_pool_t *pool);
 void sofia_presence_check_subscriptions(sofia_profile_t *profile, time_t now);
index d152a128106c6cd2faf6ce091a84a10ad33b6b94..9ebd0ee35fdebfeafc409d9835c831086ae2a60f 100644 (file)
@@ -2230,7 +2230,7 @@ void *SWITCH_THREAD_FUNC sofia_msg_thread_run_once(switch_thread_t *thread, void
        if (de) {
                pool = de->pool;
                de->pool = NULL;
-               sofia_process_dispatch_event(&de, SWITCH_FALSE);
+               sofia_process_dispatch_event(&de);
        }
 
        if (pool) {
@@ -2263,7 +2263,7 @@ void sofia_process_dispatch_event_in_thread(sofia_dispatch_event_t **dep)
        switch_thread_pool_launch_thread(&td);
 }
 
-void sofia_process_dispatch_event(sofia_dispatch_event_t **dep, switch_bool_t stack_thread)
+void sofia_process_dispatch_event(sofia_dispatch_event_t **dep)
 {
        sofia_dispatch_event_t *de = *dep;
        nua_handle_t *nh = de->nh;
@@ -2282,15 +2282,9 @@ void sofia_process_dispatch_event(sofia_dispatch_event_t **dep, switch_bool_t st
        profile->queued_events--;
        switch_mutex_unlock(profile->flag_mutex);
 
-       if (stack_thread) {
-               /* Safe to unref directly */
-               if (nh) nua_handle_unref(nh);
-               nua_unref(nua);
-       } else {
-               /* This is not a stack thread, need to call via stack (_user) using events */
-               if (nh) nua_handle_unref_user(nh);
-               nua_unref_user(nua);
-       }
+       /* This is not a stack thread, need to call via stack (_user) using events */
+       if (nh) nua_handle_unref_user(nh);
+       nua_unref_user(nua);
 }
 
 
@@ -2327,7 +2321,7 @@ void *SWITCH_THREAD_FUNC sofia_msg_thread_run(switch_thread_t *thread, void *obj
 
                if (pop) {
                        sofia_dispatch_event_t *de = (sofia_dispatch_event_t *) pop;
-                       sofia_process_dispatch_event(&de, SWITCH_FALSE);
+                       sofia_process_dispatch_event(&de);
                } else {
                        break;
                }
@@ -2382,7 +2376,7 @@ void sofia_queue_message(sofia_dispatch_event_t *de)
 
        if (mod_sofia_globals.running == 0 || !mod_sofia_globals.msg_queue) {
                /* Calling with SWITCH_TRUE as we are sure this is the stack's thread */
-               sofia_process_dispatch_event(&de, SWITCH_TRUE);
+               sofia_process_dispatch_event(&de);
                return;
        }