mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 10:33:13 +00:00
fixes crash in chan_console
There is a race condition between console_hangup() and start_stream(). It is possible for console_hangup() to be called and then the stream thread to begin after the hangup. To avoid this a check in start_stream() to make sure the pvt-owner still exists while the pvt lock is held is made. If the owner is gone that means the channel hung up and start_stream should be aborted. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@262236 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -277,6 +277,10 @@ static void *stream_monitor(void *data)
|
|||||||
res = Pa_ReadStream(pvt->stream, buf, sizeof(buf) / sizeof(int16_t));
|
res = Pa_ReadStream(pvt->stream, buf, sizeof(buf) / sizeof(int16_t));
|
||||||
pthread_testcancel();
|
pthread_testcancel();
|
||||||
|
|
||||||
|
if (!pvt->owner) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (res == paNoError)
|
if (res == paNoError)
|
||||||
ast_queue_frame(pvt->owner, &f);
|
ast_queue_frame(pvt->owner, &f);
|
||||||
}
|
}
|
||||||
@@ -352,7 +356,10 @@ static int start_stream(struct console_pvt *pvt)
|
|||||||
|
|
||||||
console_pvt_lock(pvt);
|
console_pvt_lock(pvt);
|
||||||
|
|
||||||
if (pvt->streamstate)
|
/* It is possible for console_hangup to be called before the
|
||||||
|
* stream is started, if this is the case pvt->owner will be NULL
|
||||||
|
* and start_stream should be aborted. */
|
||||||
|
if (pvt->streamstate || !pvt->owner)
|
||||||
goto return_unlock;
|
goto return_unlock;
|
||||||
|
|
||||||
pvt->streamstate = 1;
|
pvt->streamstate = 1;
|
||||||
|
Reference in New Issue
Block a user