[vlc-devel] commit: vlm: Avoid a deadlock when stoping the input. (Pierre d'Herbemont )

git version control git at videolan.org
Thu Feb 11 19:57:06 CET 2010


vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Thu Feb 11 18:11:24 2010 +0100| [966540425ec13fc7ac4113bc3aaecc2464c4ca08] | committer: Pierre d'Herbemont 

vlm: Avoid a deadlock when stoping the input.

We may be joining the input_thread inside the vlm lock, and try to vlm lock inside the stop event handler.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=966540425ec13fc7ac4113bc3aaecc2464c4ca08
---

 src/input/vlm.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/input/vlm.c b/src/input/vlm.c
index fc63d21..19f2a56 100644
--- a/src/input/vlm.c
+++ b/src/input/vlm.c
@@ -105,6 +105,16 @@ static int InputEvent( vlc_object_t *p_this, char const *psz_cmd,
         }
         vlm_SendEventMediaInstanceState( p_vlm, p_media->cfg.id, p_media->cfg.psz_name, psz_instance_name, var_GetInteger( p_input, "state" ) );
 
+        // We have ourselves been triggering the stop event.
+        // No need to wake up our manage thread, because
+        // we'll join it just after the Stop().
+        vlc_mutex_lock( &p_input->p->lock_control );
+        bool abort = p_input->p->b_abort;
+        vlc_mutex_unlock( &p_input->p->lock_control );
+
+        if (abort)
+            return VLC_SUCCESS;
+
         vlc_mutex_lock( &p_vlm->lock );
         vlc_cond_signal( &p_vlm->wait );
         vlc_mutex_unlock( &p_vlm->lock );
@@ -609,7 +619,7 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media )
                 var_DelCallback( p_input, "intf-event", InputEventPreparse, &sem_preparse );
                 vlc_sem_destroy( &sem_preparse );
 
-                input_Stop( p_input, false );
+                input_Stop( p_input, true );
                 vlc_thread_join( p_input );
                 vlc_object_release( p_input );
             }
@@ -938,7 +948,7 @@ static int vlm_ControlMediaInstanceStart( vlm_t *p_vlm, int64_t id, const char *
             return VLC_SUCCESS;
         }
 
-        input_Stop( p_input, !p_input->b_eof && !p_input->b_error );
+        input_Stop( p_input, true );
         vlc_thread_join( p_input );
 
         p_instance->p_input_resource = input_DetachResource( p_input );




More information about the vlc-devel mailing list