[vlc-devel] commit: fontconfing: join the thread exactly once ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Jan 24 14:58:15 CET 2009


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sat Jan 24 15:56:43 2009 +0200| [9e22b86335329417c7b6ce9cd7b1fff3adcfa554] | committer: Rémi Denis-Courmont 

fontconfing: join the thread exactly once

The object was typically already killed, so the thread was leaked.
Also, remove vlc_object_kill, since the thread never checks for the
detach of its own object.

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

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

diff --git a/modules/misc/freetype.c b/modules/misc/freetype.c
index a397304..b74f5eb 100644
--- a/modules/misc/freetype.c
+++ b/modules/misc/freetype.c
@@ -464,6 +464,8 @@ static vlc_object_t *FontBuilderAttach( filter_t *p_filter )
 
             var_Create( p_fontbuilder, "build-done", VLC_VAR_BOOL );
             var_SetBool( p_fontbuilder, "build-done", false );
+            var_Create( p_fontbuilder, "build-joined", VLC_VAR_BOOL );
+            var_SetBool( p_fontbuilder, "build-joined", false );
 
             if( vlc_thread_create( p_fontbuilder,
                                    "fontlist builder",
@@ -490,21 +492,17 @@ static void FontBuilderDetach( filter_t *p_filter, vlc_object_t *p_fontbuilder )
     vlc_mutex_lock( &fb_lock );
     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( b_alive )
+        if( !var_GetBool( p_fontbuilder, "build-joined" ) )
         {
-            vlc_object_kill( p_fontbuilder );
+            var_SetBool( p_fontbuilder, "build-joined", true );
             vlc_mutex_unlock( &fb_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( &fb_lock );
         }
         vlc_object_release( p_fontbuilder );




More information about the vlc-devel mailing list