diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 86aa3e0bf0..8e06012b7d 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -3117,7 +3117,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) { - return NULL; + goto end; } switch_assert(member != NULL); @@ -3414,10 +3414,12 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v switch_resample_destroy(&member->read_resampler); - switch_clear_flag_locked(member, MFLAG_ITHREAD); - switch_core_session_rwunlock(session); + end: + + switch_clear_flag_locked(member, MFLAG_ITHREAD); + return NULL; } @@ -3515,7 +3517,9 @@ static void launch_conference_loop_input(conference_member_t *member, switch_mem switch_threadattr_create(&thd_attr, pool); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); switch_set_flag_locked(member, MFLAG_ITHREAD); - switch_thread_create(&member->input_thread, thd_attr, conference_loop_input, member, pool); + if (switch_thread_create(&member->input_thread, thd_attr, conference_loop_input, member, pool) != SWITCH_STATUS_SUCCESS) { + switch_clear_flag_locked(member, MFLAG_ITHREAD); + } } /* marshall frames from the conference (or file or tts output) to the call leg */ @@ -3851,6 +3855,7 @@ static void conference_loop_output(conference_member_t *member) switch_clear_flag_locked(member, MFLAG_RUNNING); + /* Wait for the input thread to end */ if (member->input_thread) { switch_thread_join(&st, member->input_thread); } @@ -3864,11 +3869,6 @@ static void conference_loop_output(conference_member_t *member) if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { member->conference->bridge_hangup_cause = switch_channel_get_cause(channel); } - - /* Wait for the input thread to end */ - while (switch_test_flag(member, MFLAG_ITHREAD)) { - switch_cond_next(); - } } /* Sub-Routine called by a record entity inside a conference */