[vlc-devel] commit: No need to take the structure lock when finding oneself ( Rémi Denis-Courmont )

git version control git at videolan.org
Wed May 7 22:18:02 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rem at videolan.org> | Wed May  7 23:19:10 2008 +0300| [b1b63c31bdcf3823aa2a6479cda00bc5aee9624c]

No need to take the structure lock when finding oneself

as we don't go through the object table and links.

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

 src/misc/objects.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/misc/objects.c b/src/misc/objects.c
index 1f0f73c..326587c 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -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 )
     {




More information about the vlc-devel mailing list