aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authordvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2010-05-10 18:42:10 +0000
committerdvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2010-05-10 18:42:10 +0000
commit547b76254084830807d2d83c5a8830e2f84b67c7 (patch)
tree99b71f08215b38e9dad0e546dbc0d16c46c86c1c /channels
parentfe0065d41edf7c553a2c0c4cb41f1e3042cb7a6c (diff)
Merged revisions 262236 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r262236 | dvossel | 2010-05-10 13:36:10 -0500 (Mon, 10 May 2010) | 11 lines 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: http://svn.digium.com/svn/asterisk/branches/1.6.2@262237 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_console.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/channels/chan_console.c b/channels/chan_console.c
index 933cca356..9f212ff6f 100644
--- a/channels/chan_console.c
+++ b/channels/chan_console.c
@@ -277,6 +277,10 @@ static void *stream_monitor(void *data)
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 @@ static int start_stream(struct console_pvt *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;
pvt->streamstate = 1;