[vlc-devel] commit: Fixed a potential deadlock. (Laurent Aimar )

git version control git at videolan.org
Thu Jul 24 00:05:14 CEST 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Thu Jul 24 00:07:18 2008 +0200| [29f2d89e37955378d3a341dc0deaa7fdd8da40af]

Fixed a potential deadlock.

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

 modules/misc/freetype.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/modules/misc/freetype.c b/modules/misc/freetype.c
index 160d060..4e1906f 100644
--- a/modules/misc/freetype.c
+++ b/modules/misc/freetype.c
@@ -494,13 +494,22 @@ static void FontBuilderDetach( filter_t *p_filter, vlc_object_t *p_fontbuilder )
     vlc_mutex_t *lock = var_AcquireMutex( "fontbuilder" );
     if( p_fontbuilder )
     {
+        const bool b_alive = vlc_object_alive( p_fontbuilder );
+
         var_DelCallback( p_fontbuilder, "build-done", FontBuilderDone, p_filter );
 
         /* We wait for the thread on the first FontBuilderDetach */
-        if( vlc_object_alive( p_fontbuilder ) )
+        if( b_alive )
         {
             vlc_object_kill( p_fontbuilder );
+            vlc_mutex_unlock( lock );
+
+            /* We need to unlock otherwise we may not join (the thread waiting
+             * for the lock). It is safe to unlock as no one else will try a
+             * join and we have a reference on the object) */
             vlc_thread_join( p_fontbuilder );
+
+            vlc_mutex_lock( lock );
         }
         vlc_object_release( p_fontbuilder );
     }




More information about the vlc-devel mailing list