From 7c671e1d523f7707ddaa1d7d7111ffca58772bf4 Mon Sep 17 00:00:00 2001 From: Kirill Belokurov Date: Fri, 27 Jul 2007 22:24:01 +0300 Subject: Fixed race, reordered broadcaster shutdown sequence to avoid multiple access to connections list --- src/xine-engine/broadcaster.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/xine-engine/broadcaster.c b/src/xine-engine/broadcaster.c index 30cdadc7c..43390ede5 100644 --- a/src/xine-engine/broadcaster.c +++ b/src/xine-engine/broadcaster.c @@ -352,6 +352,17 @@ broadcaster_t *_x_init_broadcaster(xine_stream_t *stream, int port) void _x_close_broadcaster(broadcaster_t *this) { + this->running = 0; + pthread_cancel(this->manager_thread); + pthread_join(this->manager_thread,NULL); + close(this->msock); + + if (this->stream->video_fifo) + this->stream->video_fifo->unregister_put_cb(this->stream->video_fifo, video_put_cb); + + if(this->stream->audio_fifo) + this->stream->audio_fifo->unregister_put_cb(this->stream->audio_fifo, audio_put_cb); + xine_list_iterator_t ite; while ( (ite = xine_list_front(this->connections)) ) { @@ -362,18 +373,9 @@ void _x_close_broadcaster(broadcaster_t *this) xine_list_remove (this->connections, ite); } xine_list_delete(this->connections); - - this->running = 0; - close(this->msock); - pthread_mutex_lock( &this->lock ); - pthread_cancel(this->manager_thread); - pthread_join(this->manager_thread,NULL); - - this->stream->video_fifo->unregister_put_cb(this->stream->video_fifo, video_put_cb); - if(this->stream->audio_fifo) - this->stream->audio_fifo->unregister_put_cb(this->stream->audio_fifo, audio_put_cb); - + pthread_mutex_destroy( &this->lock ); + free(this); } -- cgit v1.2.3