prevent buffer destroy race

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13219 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-05-01 21:31:16 +00:00
parent e9c8418a89
commit fae50b4197
2 changed files with 10 additions and 1 deletions

View File

@ -915,6 +915,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
} else {
switch_size_t x;
for (x = 0; x < frames; x++) {
if (switch_channel_down(session->channel) || !session->raw_write_buffer) {
goto error;
}
if ((session->raw_write_frame.datalen = (uint32_t)
switch_buffer_read(session->raw_write_buffer, session->raw_write_frame.data, bytes)) != 0) {
int rate;

View File

@ -879,9 +879,15 @@ SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session, s
switch_mutex_unlock(session->resample_mutex);
/* clear indications */
switch_core_session_flush_message(session);
/* wipe these, they will be recreated if need be */
switch_buffer_destroy(&session->raw_read_buffer);
switch_mutex_lock(session->codec_write_mutex);
switch_buffer_destroy(&session->raw_write_buffer);
switch_mutex_unlock(session->codec_write_mutex);
switch_mutex_lock(session->codec_read_mutex);
switch_buffer_destroy(&session->raw_read_buffer);
switch_mutex_unlock(session->codec_read_mutex);
if (flush_dtmf) {
while ((has = switch_channel_has_dtmf(channel))) {