]> git.sesse.net Git - vlc/commitdiff
No need to take the structure lock when finding oneself
authorRémi Denis-Courmont <rem@videolan.org>
Wed, 7 May 2008 20:19:10 +0000 (23:19 +0300)
committerRémi Denis-Courmont <rem@videolan.org>
Wed, 7 May 2008 20:19:10 +0000 (23:19 +0300)
as we don't go through the object table and links.

src/misc/objects.c

index 1f0f73cfa2a49c82d31a2ec56f9a35ca8030e45b..326587c4c0c5e080e89a6aed0ceab4a2123ccc4c 100644 (file)
@@ -742,18 +742,15 @@ void * __vlc_object_find( vlc_object_t *p_this, int i_type, int i_mode )
 {
     vlc_object_t *p_found;
 
-    vlc_mutex_lock( &structure_lock );
-
-    assert( vlc_internals( p_this )->i_refcount > 0 );
-
     /* If we are of the requested type ourselves, don't look further */
     if( !(i_mode & FIND_STRICT) && p_this->i_object_type == i_type )
     {
         vlc_object_yield( p_this );
-        vlc_mutex_unlock( &structure_lock );
         return p_this;
     }
 
+    vlc_mutex_lock( &structure_lock );
+
     /* Otherwise, recursively look for the object */
     if( (i_mode & 0x000f) == FIND_ANYWHERE )
     {
@@ -795,18 +792,17 @@ void * __vlc_object_find_name( vlc_object_t *p_this, const char *psz_name,
 {
     vlc_object_t *p_found;
 
-    vlc_mutex_lock( &structure_lock );
-
     /* If have the requested name ourselves, don't look further */
     if( !(i_mode & FIND_STRICT)
         && p_this->psz_object_name
         && !strcmp( p_this->psz_object_name, psz_name ) )
     {
         vlc_object_yield( p_this );
-        vlc_mutex_unlock( &structure_lock );
         return p_this;
     }
 
+    vlc_mutex_lock( &structure_lock );
+
     /* Otherwise, recursively look for the object */
     if( (i_mode & 0x000f) == FIND_ANYWHERE )
     {