Changeset b44e7cc21fd5d9eab3378b8d277135b3975b2b15

Show
Ignore:
Timestamp:
14/03/07 17:10:14 (2 years ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1173888614 +0000
git-parent:

[f49d815ad696220ebe2a97cdd8d2f09d129e0022]

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

Code simplification

Files:

Legend:

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

    rf7705ea rb44e7cc  
    204204    const sigset_t *set = (sigset_t *)data; 
    205205    time_t abort_time = 0; 
    206     vlc_bool_t b_die = VLC_FALSE; 
    207  
    208 #ifdef __APPLE__ 
    209     /* We really prefer the "force quit" menu item to act immediately */ 
    210     b_die = VLC_TRUE; 
    211 #endif 
    212206 
    213207    for (;;) 
     
    227221 
    228222        pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state); 
    229         if (!b_die
     223        if (abort_time == 0
    230224        { 
    231             b_die = VLC_TRUE
    232             abort_time = time (NULL)
     225            time (&abort_time)
     226            abort_time += 2
    233227 
    234228            fprintf (stderr, "signal %d received, terminating vlc - do it " 
     
    238232            Kill (); 
    239233        } 
    240         else if( time( NULL ) > abort_time + 2 ) 
    241         { 
    242             /* If user asks again 1 or 2 seconds later, die badly */ 
     234        else 
     235        if (time (NULL) <= abort_time) 
     236    { 
     237            /* If user asks again more than 2 seconds later, die badly */ 
    243238            pthread_sigmask (SIG_UNBLOCK, set, NULL); 
    244239            fprintf (stderr, "user insisted too much, dying badly\n"); 
     
    251246 
    252247 
    253 #include <stdbool.h> 
     248static void KillOnce (void) 
     249
     250    VLC_Die (0); 
     251
     252 
    254253static void Kill (void) 
    255254{ 
    256     static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; 
    257     static bool killed = false;; 
    258     pthread_mutex_lock (&lock); 
    259     if (!killed) 
    260     { 
    261         VLC_Die (0); 
    262         killed = true; 
    263     } 
    264     pthread_mutex_unlock (&lock); 
     255    static pthread_once_t once = PTHREAD_ONCE_INIT; 
     256    pthread_once (KillOnce); 
    265257} 
    266258