]> git.sesse.net Git - vlc/commitdiff
objects: Don't lock parent in vlc_object_attach(). It creates quite hard to resolve...
authorPierre d'Herbemont <pdherbemont@videolan.org>
Fri, 30 May 2008 12:46:13 +0000 (14:46 +0200)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Fri, 30 May 2008 12:46:32 +0000 (14:46 +0200)
src/misc/objects.c

index d4a5a6b69a613bd157aa7cc5d7e2bc60b5bb5f62..53fd89b632abb125e872970bb6142d84ef6e3187 100644 (file)
@@ -837,15 +837,18 @@ void __vlc_object_attach( vlc_object_t *p_this, vlc_object_t *p_parent )
     assert (!p_this->p_parent);
     p_this->p_parent = p_parent;
 
-    vlc_object_lock( p_this->p_parent );
-
     /* Attach the child to its parent */
     vlc_object_internals_t *priv = vlc_internals( p_parent );
     INSERT_ELEM( priv->pp_children, priv->i_children, priv->i_children,
                  p_this );
 
-    /* Kill the object if parent is already dead */
-    if( !vlc_object_alive( p_this->p_parent) )
+    /* Kill the object if parent is already dead.
+     * Note: We should surely lock parent here, but that would
+     * create quite a few dead lock case. Hopefully, it
+     * is perfectly safe to do it that way. We only risk
+     * receiving kill event twice. But given current API
+     * it is ok. */
+    if( p_this->p_parent->b_die )
         vlc_object_kill( p_this );
 
     vlc_object_unlock( p_this->p_parent );