Changeset c13d67b82c674fffe5d65656aff7484c227a74a1

Show
Ignore:
Timestamp:
03/01/07 21:09:41 (1 year ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1172779781 +0000
git-parent:

[1d58919125812d569c23bde687e42fca86858e33]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1172779781 +0000
Message:

Fix race condition and simplify SigHandler?
Missing piece pointed out by Pierre d'H.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/vlc.c

    r1d58919 rc13d67b  
    4040extern void __wgetmainargs(int *argc, wchar_t ***wargv, wchar_t ***wenviron, 
    4141                           int expand_wildcards, int *startupinfo); 
     42static inline void Kill(void) { } 
    4243#else 
    4344 
     
    4546# include <time.h> 
    4647# include <pthread.h> 
    47 # include <stdbool.h> 
    48  
    49 static struct 
    50 
    51     bool flag; 
    52     pthread_mutex_t lock; 
    53 } live = { true, PTHREAD_MUTEX_INITIALIZER }; 
    54  
     48 
     49static void Kill (void); 
    5550static void *SigHandler (void *set); 
    5651#endif 
     
    176171    VLC_CleanUp( 0 ); 
    177172 
     173    Kill (); 
     174 
    178175    /* Destroy the libvlc structure */ 
    179176    VLC_Destroy( 0 ); 
     
    219216 
    220217            /* Acknowledge the signal received */ 
    221             pthread_mutex_lock (&live.lock); 
    222             if (live.flag) 
    223             { 
    224                 VLC_Die (0); 
    225                 live.flag = false; 
    226             } 
    227             pthread_mutex_unlock (&live.lock); 
     218            Kill (); 
    228219        } 
    229220        else if( time( NULL ) > abort_time + 2 ) 
     
    238229    /* Never reached */ 
    239230} 
     231 
     232 
     233static void KillOnce (void) 
     234{ 
     235    VLC_Die (0); 
     236} 
     237 
     238 
     239static void Kill (void) 
     240{ 
     241    static pthread_once_t once = PTHREAD_ONCE_INIT; 
     242    pthread_once (&once, KillOnce); 
     243} 
     244 
    240245#endif 
    241246