mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 17:38:59 +00:00
fix obscure race condition
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7311 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -503,9 +503,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session
|
||||
switch_channel_t *tchannel = switch_core_session_get_channel(tsession);
|
||||
switch_frame_t *read_frame, write_frame = { 0 };
|
||||
switch_codec_t codec = {0};
|
||||
int16_t buf[1024];
|
||||
int16_t buf[8192];
|
||||
switch_codec_t *tread_codec = switch_core_session_get_read_codec(tsession);
|
||||
|
||||
int tlen = tread_codec->implementation->bytes_per_frame;
|
||||
|
||||
ep = switch_core_session_alloc(session, sizeof(*ep));
|
||||
|
||||
switch_channel_pre_answer(channel);
|
||||
@@ -543,7 +544,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session
|
||||
|
||||
|
||||
if (switch_core_media_bug_add(tsession, eavesdrop_callback, ep, 0,
|
||||
SMBF_READ_STREAM | SMBF_WRITE_STREAM | SMBF_READ_REPLACE | SMBF_WRITE_REPLACE | SMBF_READ_PING,
|
||||
SMBF_READ_STREAM | SMBF_WRITE_STREAM | SMBF_READ_REPLACE | SMBF_WRITE_REPLACE | SMBF_READ_PING | SMBF_THREAD_LOCK,
|
||||
&bug) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot attach bug\n");
|
||||
goto end;
|
||||
@@ -630,11 +631,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session
|
||||
switch_buffer_unlock(ep->w_buffer);
|
||||
}
|
||||
|
||||
|
||||
if (len > tread_codec->implementation->bytes_per_frame) {
|
||||
len = tread_codec->implementation->bytes_per_frame;
|
||||
if (len > tlen) {
|
||||
len = tlen;
|
||||
}
|
||||
|
||||
|
||||
if (switch_buffer_inuse(ep->buffer) >= len) {
|
||||
switch_buffer_lock(ep->buffer);
|
||||
while (switch_buffer_inuse(ep->buffer) >= len) {
|
||||
|
Reference in New Issue
Block a user