Commit b44e7cc2 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Code simplification

parent f49d815a
...@@ -203,12 +203,6 @@ static void *SigHandler (void *data) ...@@ -203,12 +203,6 @@ static void *SigHandler (void *data)
{ {
const sigset_t *set = (sigset_t *)data; const sigset_t *set = (sigset_t *)data;
time_t abort_time = 0; time_t abort_time = 0;
vlc_bool_t b_die = VLC_FALSE;
#ifdef __APPLE__
/* We really prefer the "force quit" menu item to act immediately */
b_die = VLC_TRUE;
#endif
for (;;) for (;;)
{ {
...@@ -226,10 +220,10 @@ static void *SigHandler (void *data) ...@@ -226,10 +220,10 @@ static void *SigHandler (void *data)
* signals to a libvlc structure having been destroyed */ * signals to a libvlc structure having been destroyed */
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state); pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state);
if (!b_die) if (abort_time == 0)
{ {
b_die = VLC_TRUE; time (&abort_time);
abort_time = time (NULL); abort_time += 2;
fprintf (stderr, "signal %d received, terminating vlc - do it " fprintf (stderr, "signal %d received, terminating vlc - do it "
"again in case it gets stuck\n", i_signal); "again in case it gets stuck\n", i_signal);
...@@ -237,9 +231,10 @@ static void *SigHandler (void *data) ...@@ -237,9 +231,10 @@ static void *SigHandler (void *data)
/* Acknowledge the signal received */ /* Acknowledge the signal received */
Kill (); Kill ();
} }
else if( time( NULL ) > abort_time + 2 ) else
{ if (time (NULL) <= abort_time)
/* If user asks again 1 or 2 seconds later, die badly */ {
/* If user asks again more than 2 seconds later, die badly */
pthread_sigmask (SIG_UNBLOCK, set, NULL); pthread_sigmask (SIG_UNBLOCK, set, NULL);
fprintf (stderr, "user insisted too much, dying badly\n"); fprintf (stderr, "user insisted too much, dying badly\n");
abort (); abort ();
...@@ -250,18 +245,15 @@ static void *SigHandler (void *data) ...@@ -250,18 +245,15 @@ static void *SigHandler (void *data)
} }
#include <stdbool.h> static void KillOnce (void)
{
VLC_Die (0);
}
static void Kill (void) static void Kill (void)
{ {
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; static pthread_once_t once = PTHREAD_ONCE_INIT;
static bool killed = false;; pthread_once (KillOnce);
pthread_mutex_lock (&lock);
if (!killed)
{
VLC_Die (0);
killed = true;
}
pthread_mutex_unlock (&lock);
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment