mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-18 09:32:34 +00:00
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:
parent
e9c8418a89
commit
fae50b4197
@ -915,6 +915,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
|
|||||||
} else {
|
} else {
|
||||||
switch_size_t x;
|
switch_size_t x;
|
||||||
for (x = 0; x < frames; 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)
|
if ((session->raw_write_frame.datalen = (uint32_t)
|
||||||
switch_buffer_read(session->raw_write_buffer, session->raw_write_frame.data, bytes)) != 0) {
|
switch_buffer_read(session->raw_write_buffer, session->raw_write_frame.data, bytes)) != 0) {
|
||||||
int rate;
|
int rate;
|
||||||
|
@ -879,9 +879,15 @@ SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session, s
|
|||||||
switch_mutex_unlock(session->resample_mutex);
|
switch_mutex_unlock(session->resample_mutex);
|
||||||
/* clear indications */
|
/* clear indications */
|
||||||
switch_core_session_flush_message(session);
|
switch_core_session_flush_message(session);
|
||||||
|
|
||||||
/* wipe these, they will be recreated if need be */
|
/* 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_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) {
|
if (flush_dtmf) {
|
||||||
while ((has = switch_channel_has_dtmf(channel))) {
|
while ((has = switch_channel_has_dtmf(channel))) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user