Commit 4bd079da authored by Jean-Paul Saman's avatar Jean-Paul Saman

Add some sanity checking and extra locking to guard against concurrent access patterns in core.

parent 65382e4f
...@@ -406,14 +406,17 @@ void input_StopThread( input_thread_t *p_input ) ...@@ -406,14 +406,17 @@ void input_StopThread( input_thread_t *p_input )
*/ */
void input_DestroyThread( input_thread_t *p_input ) void input_DestroyThread( input_thread_t *p_input )
{ {
/* Join the thread */ if( p_input )
vlc_thread_join( p_input ); {
/* Join the thread */
vlc_thread_join( p_input );
/* Delete input lock (only after thread joined) */ /* Delete input lock (only after thread joined) */
vlc_mutex_destroy( &p_input->lock_control ); vlc_mutex_destroy( &p_input->lock_control );
/* TODO: maybe input_DestroyThread should also delete p_input instead /* TODO: maybe input_DestroyThread should also delete p_input instead
* of the playlist but I'm not sure if it's possible */ * of the playlist but I'm not sure if it's possible */
}
} }
/***************************************************************************** /*****************************************************************************
...@@ -423,13 +426,13 @@ void input_DestroyThread( input_thread_t *p_input ) ...@@ -423,13 +426,13 @@ void input_DestroyThread( input_thread_t *p_input )
*****************************************************************************/ *****************************************************************************/
static int Run( input_thread_t *p_input ) static int Run( input_thread_t *p_input )
{ {
/* Signal that the thread is launched */
vlc_thread_ready( p_input ); vlc_thread_ready( p_input );
if( Init( p_input, VLC_FALSE ) ) if( Init( p_input, VLC_FALSE ) )
{ {
/* If we failed, wait before we are killed, and exit */ /* If we failed, wait before we are killed, and exit */
p_input->b_error = VLC_TRUE; p_input->b_error = VLC_TRUE;
/* Signal that the thread is launched */
Error( p_input ); Error( p_input );
......
...@@ -734,7 +734,7 @@ int playlist_Clear( playlist_t * p_playlist ) ...@@ -734,7 +734,7 @@ int playlist_Clear( playlist_t * p_playlist )
int i; int i;
for( i = p_playlist->i_size; i > 0 ; i-- ) for( i = p_playlist->i_size; i > 0 ; i-- )
{ {
playlist_Delete( p_playlist, p_playlist->pp_items[0]->input.i_id ); playlist_LockDelete( p_playlist, p_playlist->pp_items[0]->input.i_id );
} }
for( i = 0 ; i< p_playlist->i_views; i++ ) for( i = 0 ; i< p_playlist->i_views; i++ )
{ {
......
...@@ -657,6 +657,8 @@ static void RunThread ( playlist_t *p_playlist ) ...@@ -657,6 +657,8 @@ static void RunThread ( playlist_t *p_playlist )
/* Destroy input */ /* Destroy input */
input_DestroyThread( p_input ); input_DestroyThread( p_input );
vlc_mutex_lock( &p_playlist->object_lock );
/* Unlink current input /* Unlink current input
* (_after_ input_DestroyThread for vout garbage collector) */ * (_after_ input_DestroyThread for vout garbage collector) */
vlc_object_detach( p_input ); vlc_object_detach( p_input );
...@@ -796,6 +798,9 @@ static void RunThread ( playlist_t *p_playlist ) ...@@ -796,6 +798,9 @@ static void RunThread ( playlist_t *p_playlist )
/* Destroy input */ /* Destroy input */
input_DestroyThread( p_input ); input_DestroyThread( p_input );
vlc_mutex_lock( &p_playlist->object_lock );
/* Unlink current input (_after_ input_DestroyThread for vout /* Unlink current input (_after_ input_DestroyThread for vout
* garbage collector)*/ * garbage collector)*/
vlc_object_detach( p_input ); vlc_object_detach( p_input );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment