From: Anthony Minessale Date: Mon, 14 Feb 2011 17:44:36 +0000 (-0600) Subject: fix race with media bug exiting from write frame while read frame is trying to use it X-Git-Tag: v1.2-rc1~187^2~8^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1341a75ad899d35f9003e4514cb5c8f724e0e7da;p=thirdparty%2Ffreeswitch.git fix race with media bug exiting from write frame while read frame is trying to use it --- diff --git a/src/switch_core_io.c b/src/switch_core_io.c index decb587ef7..4e1c7075b5 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -318,11 +318,24 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi switch_codec_t *use_codec = read_frame->codec; if (do_bugs) { switch_thread_rwlock_wrlock(session->bug_rwlock); + if (!session->bugs) { + do_bugs = 0; + switch_thread_rwlock_unlock(session->bug_rwlock); + goto done; + } + if (!switch_core_codec_ready(&session->bug_codec)) { switch_core_codec_copy(read_frame->codec, &session->bug_codec, NULL); } use_codec = &session->bug_codec; switch_thread_rwlock_unlock(session->bug_rwlock); + + switch_thread_rwlock_wrlock(session->bug_rwlock); + if (!session->bugs) { + do_bugs = 0; + } + switch_thread_rwlock_unlock(session->bug_rwlock); + if (!do_bugs) goto done; } if (switch_test_flag(read_frame, SFF_PLC)) {