diff options
author | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-05-10 18:36:10 +0000 |
---|---|---|
committer | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-05-10 18:36:10 +0000 |
commit | 26a012f4f3169d720656bd9829e80207e47484f8 (patch) | |
tree | 972c13890f02e57b4cafff4f869a6b1263eafa94 /channels/chan_console.c | |
parent | f8fd696cc55229097ad511a17d6c9c7583d701f5 (diff) |
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/trunk@262236 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_console.c')
-rw-r--r-- | channels/chan_console.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/channels/chan_console.c b/channels/chan_console.c index 93a51ae4e..6c566e9c9 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; |