[mod_sofia] sofia_process_dispatch_event() should unref all handles via sofia stack

This commit is contained in:
Andrey Volk 2021-06-07 20:46:58 +03:00
parent c985c90cbb
commit 81fff857c5
3 changed files with 9 additions and 15 deletions

View File

@ -1343,7 +1343,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
de->session = session; de->session = session;
} }
sofia_process_dispatch_event(&de, SWITCH_FALSE); sofia_process_dispatch_event(&de);
switch_mutex_unlock(tech_pvt->sofia_mutex); switch_mutex_unlock(tech_pvt->sofia_mutex);

View 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); 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); 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_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); 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); 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); void sofia_presence_check_subscriptions(sofia_profile_t *profile, time_t now);

View File

@ -2230,7 +2230,7 @@ void *SWITCH_THREAD_FUNC sofia_msg_thread_run_once(switch_thread_t *thread, void
if (de) { if (de) {
pool = de->pool; pool = de->pool;
de->pool = NULL; de->pool = NULL;
sofia_process_dispatch_event(&de, SWITCH_FALSE); sofia_process_dispatch_event(&de);
} }
if (pool) { if (pool) {
@ -2263,7 +2263,7 @@ void sofia_process_dispatch_event_in_thread(sofia_dispatch_event_t **dep)
switch_thread_pool_launch_thread(&td); 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; sofia_dispatch_event_t *de = *dep;
nua_handle_t *nh = de->nh; 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--; profile->queued_events--;
switch_mutex_unlock(profile->flag_mutex); switch_mutex_unlock(profile->flag_mutex);
if (stack_thread) { /* This is not a stack thread, need to call via stack (_user) using events */
/* Safe to unref directly */ if (nh) nua_handle_unref_user(nh);
if (nh) nua_handle_unref(nh); nua_unref_user(nua);
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);
}
} }
@ -2327,7 +2321,7 @@ void *SWITCH_THREAD_FUNC sofia_msg_thread_run(switch_thread_t *thread, void *obj
if (pop) { if (pop) {
sofia_dispatch_event_t *de = (sofia_dispatch_event_t *) pop; sofia_dispatch_event_t *de = (sofia_dispatch_event_t *) pop;
sofia_process_dispatch_event(&de, SWITCH_FALSE); sofia_process_dispatch_event(&de);
} else { } else {
break; 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) { 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 */ /* 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; return;
} }