From 633743117c7067bb7f7a7a12f2edbe6bb463a366 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Thu, 25 Jun 2009 20:24:34 -0500 Subject: [PATCH] mutex fixes We need to make sure that should_run is protected by the mutex. --- signal.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/signal.c b/signal.c index 6fdf6bc..6482264 100644 --- a/signal.c +++ b/signal.c @@ -46,14 +46,18 @@ void *signal_thread(void *arg) sigaction(SIGINT, &temp, NULL); sigaction(SIGTERM, &temp, NULL); + pthread_mutex_lock(&queue_guard); while(should_run) { + pthread_mutex_unlock(&queue_guard); sigfillset(&sigset); sigwait(&sigset, &sig); switch (sig) { case SIGINT: case SIGTERM: printf("This is where we shut down.\n"); + pthread_mutex_lock(&queue_guard); should_run = 0; + pthread_mutex_unlock(&queue_guard); break; default: printf("espeakup caught signal %d\n", sig);