[vlc-devel] commit: objects: Don't lock parent in vlc_object_attach(). It creates quite hard to resolve dead lock, and hopefully it is safe enough not to lock here. We only risk receiving kill event twice. But given current API it is ok. ( Pierre d'Herbemont )

git version control git at videolan.org
Fri May 30 14:45:18 CEST 2008


vlc | branch: master | Pierre d'Herbemont <pdherbemont at videolan.org> | Fri May 30 14:46:13 2008 +0200| [99e8bcdd96b8b3d0997acac002de434f603a75c4]

objects: Don't lock parent in vlc_object_attach(). It creates quite hard to resolve dead lock, and hopefully it is safe enough not to lock here. We only risk receiving kill event twice. But given current API it is ok.

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

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

diff --git a/src/misc/objects.c b/src/misc/objects.c
index d4a5a6b..53fd89b 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -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 );




More information about the vlc-devel mailing list