[vlc-commits] commit: ML: Avoid deadlocks (Srikanth Raju )

git at videolan.org git at videolan.org
Sat Jan 15 21:22:54 CET 2011


vlc | branch: master | Srikanth Raju <srikiraju at gmail.com> | Sun Jan 16 01:34:57 2011 +0530| [a607963a10fb1d2ea8f4715cb237486677861fa7] | committer: Srikanth Raju 

ML: Avoid deadlocks

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

 modules/media_library/ml_watch.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/modules/media_library/ml_watch.c b/modules/media_library/ml_watch.c
index 7113116..502a6af 100644
--- a/modules/media_library/ml_watch.c
+++ b/modules/media_library/ml_watch.c
@@ -173,13 +173,9 @@ static void detachItemEvents( media_library_t *p_ml, input_item_t *p_item )
 void watch_Close( media_library_t *p_ml )
 {
     playlist_t *p_pl = pl_Get( p_ml );
-    var_DelCallback( p_pl, "item-current", watch_PlaylistItemCurrent, p_ml );
-    var_DelCallback( p_pl, "playlist-item-append", watch_PlaylistItemAppend, p_ml );
     var_DelCallback( p_pl, "playlist-item-deleted", watch_PlaylistItemDeleted, p_ml );
-
-    /* Stop the watch thread and join in */
-    vlc_object_kill( p_ml->p_sys->p_watch );
-    vlc_thread_join( p_ml->p_sys->p_watch );
+    var_DelCallback( p_pl, "playlist-item-append", watch_PlaylistItemAppend, p_ml );
+    var_DelCallback( p_pl, "item-current", watch_PlaylistItemCurrent, p_ml );
 
     /* Flush item list */
     il_foreachhashlist( p_ml->p_sys->p_watch->p_hlist, p_elt, ixx )
@@ -190,6 +186,10 @@ void watch_Close( media_library_t *p_ml )
     }
     item_list_destroy( p_ml->p_sys->p_watch );
 
+    /* Stop the watch thread and join in */
+    vlc_object_kill( p_ml->p_sys->p_watch );
+    vlc_thread_join( p_ml->p_sys->p_watch );
+
     /* Clear up other stuff */
     vlc_mutex_destroy( &p_ml->p_sys->p_watch->lock );
     vlc_cond_destroy( &p_ml->p_sys->p_watch->cond );
@@ -558,12 +558,16 @@ static void watch_ProcessAppendQueue( media_library_t* p_ml )
         vlc_mutex_lock( &p_wt->list_mutex );
         p_media = media_New( p_ml, i_media_id, ML_MEDIA, true );
         if( p_media == NULL )
+        {
+            vlc_mutex_unlock( &p_wt->list_mutex );
             continue;
+        }
         /* If duplicate, then it just continues */
         i_ret = __watch_add_Item( p_ml, p_item, p_media, true );
         if( i_ret != VLC_SUCCESS )
         {
             ml_gc_decref( p_media );
+            vlc_mutex_unlock( &p_wt->list_mutex );
             continue;
         }
 



More information about the vlc-commits mailing list