diff --git a/src/mod/endpoints/mod_rtmp/mod_rtmp.c b/src/mod/endpoints/mod_rtmp/mod_rtmp.c index e00fcd0b6f..9d2039e37e 100644 --- a/src/mod/endpoints/mod_rtmp/mod_rtmp.c +++ b/src/mod/endpoints/mod_rtmp/mod_rtmp.c @@ -266,10 +266,6 @@ switch_status_t rtmp_on_hangup(switch_core_session_t *session) rtmp_notify_call_state(session); rtmp_send_onhangup(session); - switch_mutex_lock(tech_pvt->rtmp_session->count_mutex); - tech_pvt->rtmp_session->active_sessions--; - switch_mutex_unlock(tech_pvt->rtmp_session->count_mutex); - switch_core_hash_delete_wrlock(tech_pvt->rtmp_session->session_hash, switch_core_session_get_uuid(session), tech_pvt->rtmp_session->session_rwlock); switch_mutex_lock(tech_pvt->rtmp_session->profile->mutex); @@ -279,6 +275,10 @@ switch_status_t rtmp_on_hangup(switch_core_session_t *session) } switch_mutex_unlock(tech_pvt->rtmp_session->profile->mutex); + switch_mutex_lock(tech_pvt->rtmp_session->count_mutex); + tech_pvt->rtmp_session->active_sessions--; + switch_mutex_unlock(tech_pvt->rtmp_session->count_mutex); + #ifndef RTMP_DONT_HOLD if (switch_channel_test_flag(channel, CF_HOLD)) { switch_channel_mark_hold(channel, SWITCH_FALSE);