diff --git a/src/mod/endpoints/mod_rtmp/mod_rtmp.c b/src/mod/endpoints/mod_rtmp/mod_rtmp.c index 844b1483d0..164491a70b 100644 --- a/src/mod/endpoints/mod_rtmp/mod_rtmp.c +++ b/src/mod/endpoints/mod_rtmp/mod_rtmp.c @@ -250,6 +250,7 @@ switch_status_t rtmp_on_hangup(switch_core_session_t *session) tech_pvt = switch_core_session_get_private(session); assert(tech_pvt != NULL); + switch_thread_rwlock_wrlock(tech_pvt->rtmp_session->rwlock); switch_clear_flag_locked(tech_pvt, TFLAG_IO); //switch_thread_cond_signal(tech_pvt->cond); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel)); @@ -286,6 +287,8 @@ switch_status_t rtmp_on_hangup(switch_core_session_t *session) } #endif + switch_thread_rwlock_unlock(tech_pvt->rtmp_session->rwlock); + return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/endpoints/mod_rtmp/rtmp.c b/src/mod/endpoints/mod_rtmp/rtmp.c index d334feea4b..1c3bee44bc 100644 --- a/src/mod/endpoints/mod_rtmp/rtmp.c +++ b/src/mod/endpoints/mod_rtmp/rtmp.c @@ -906,10 +906,12 @@ switch_status_t rtmp_handle_data(rtmp_session_t *rsession) rtmp_handle_invoke(rsession, rsession->amfnumber); break; case RTMP_TYPE_AUDIO: /* Audio data */ + switch_thread_rwlock_wrlock(rsession->rwlock); if (rsession->tech_pvt) { uint16_t len = state->origlen; if (!rsession->tech_pvt->readbuf) { + switch_thread_rwlock_unlock(rsession->rwlock); return SWITCH_STATUS_FALSE; } @@ -936,6 +938,8 @@ switch_status_t rtmp_handle_data(rtmp_session_t *rsession) } switch_mutex_unlock(rsession->tech_pvt->readbuf_mutex); } + switch_thread_rwlock_unlock(rsession->rwlock); + break; case RTMP_TYPE_VIDEO: /* Video data */ case RTMP_TYPE_METADATA: /* Metadata */