[asterisk-commits] dvossel: trunk r262236 - /trunk/channels/chan_console.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon May 10 13:36:14 CDT 2010
Author: dvossel
Date: Mon May 10 13:36:10 2010
New Revision: 262236
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=262236
Log:
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.
Modified:
trunk/channels/chan_console.c
Modified: trunk/channels/chan_console.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_console.c?view=diff&rev=262236&r1=262235&r2=262236
==============================================================================
--- trunk/channels/chan_console.c (original)
+++ trunk/channels/chan_console.c Mon May 10 13:36:10 2010
@@ -277,6 +277,10 @@
res = Pa_ReadStream(pvt->stream, buf, sizeof(buf) / sizeof(int16_t));
pthread_testcancel();
+ if (!pvt->owner) {
+ return NULL;
+ }
+
if (res == paNoError)
ast_queue_frame(pvt->owner, &f);
}
@@ -352,7 +356,10 @@
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;
pvt->streamstate = 1;
More information about the asterisk-commits
mailing list