[vlc-devel] commit: macosx: Fix a deadlock in the broken -[VLCPlaylist isItem: inNode: checkItemExistence:]. Fixes #1711 (Deleting a playing item' s parent item result in a trivial deadlock on Mac OS X.) (Pierre d' Herbemont )

git version control git at videolan.org
Tue Jul 15 19:31:49 CEST 2008


vlc | branch: master | Pierre d'Herbemont <pdherbemont at videolan.org> | Tue Jul 15 13:42:52 2008 +0200| [bfef7653c3e70dff098ac61b900a5c9b860542a7]

macosx: Fix a deadlock in the broken -[VLCPlaylist isItem: inNode: checkItemExistence:]. Fixes #1711 (Deleting a playing item's parent item result in a trivial deadlock on Mac OS X.)

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

 modules/gui/macosx/playlist.m |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/modules/gui/macosx/playlist.m b/modules/gui/macosx/playlist.m
index 0b0d130..69d9fbb 100644
--- a/modules/gui/macosx/playlist.m
+++ b/modules/gui/macosx/playlist.m
@@ -565,6 +565,14 @@
 - (BOOL)isItem: (playlist_item_t *)p_item
                     inNode: (playlist_item_t *)p_node
                     checkItemExistence:(BOOL)b_check
+{
+    [self isItem:p_item inNode:p_node checkItemExistence:b_check locked:NO];
+}
+
+- (BOOL)isItem: (playlist_item_t *)p_item
+                    inNode: (playlist_item_t *)p_node
+                    checkItemExistence:(BOOL)b_check
+                    locked:(BOOL)b_locked
 
 {
     playlist_t * p_playlist = pl_Yield( VLCIntf );
@@ -585,7 +593,7 @@
     if ( p_temp_item )
     {
         int i;
-        PL_LOCK;
+        if(!b_locked) PL_LOCK;
 
         if( b_check )
         {
@@ -597,8 +605,8 @@
                 if( ARRAY_VAL( p_playlist->all_items, i) == p_item ) break;
                 else if ( i == p_playlist->all_items.i_size - 1 )
                 {
+                    if(!b_locked) PL_UNLOCK;
                     vlc_object_release( p_playlist );
-                    PL_UNLOCK;
                     return NO;
                 }
             }
@@ -609,12 +617,12 @@
             p_temp_item = p_temp_item->p_parent;
             if( p_temp_item == p_node )
             {
-                PL_UNLOCK;
+                if(!b_locked) PL_UNLOCK;
                 vlc_object_release( p_playlist );
                 return YES;
             }
         }
-        PL_UNLOCK;
+        if(!b_locked) PL_UNLOCK;
     }
 
     vlc_object_release( p_playlist );
@@ -636,7 +644,7 @@
             }
             if( [self isItem: [[o_items objectAtIndex:i] pointerValue]
                     inNode: [[o_nodes objectAtIndex:j] pointerValue]
-                    checkItemExistence: NO] )
+                    checkItemExistence: NO locked:NO] )
             {
                 [o_items removeObjectAtIndex:i];
                 /* We need to execute the next iteration with the same index
@@ -841,7 +849,7 @@
             if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
                 [self isItem: p_playlist->status.p_item inNode:
                         ((playlist_item_t *)[o_item pointerValue])
-                        checkItemExistence: NO] == YES )
+                        checkItemExistence: NO locked:YES] == YES )
                 // if current item is in selected node and is playing then stop playlist
                 playlist_Stop( p_playlist );
     




More information about the vlc-devel mailing list