From 3687f16b09d7ff37f73ca0f98acd8dedd4ce18c1 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Thu, 25 Jun 2009 17:05:51 -0500 Subject: [PATCH] wait for acknowledgements correctly pthread_cond_wait() can have spurious wakeups, so we need to be sure that the condition is actually true when we return from this function. Thanks to Chris Brannon for the patch. --- softsynth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/softsynth.c b/softsynth.c index 35d01fd..d3fe1b1 100644 --- a/softsynth.c +++ b/softsynth.c @@ -170,7 +170,8 @@ static void request_espeak_stop(void) pthread_mutex_lock(&queue_guard); runner_must_stop = 1; pthread_cond_signal(&runner_awake); /* Wake runner, if necessary. */ - pthread_cond_wait(&stop_acknowledged, &queue_guard); + while(runner_must_stop == 1) + pthread_cond_wait(&stop_acknowledged, &queue_guard); /* wait for acknowledgement. */ pthread_mutex_unlock(&queue_guard); }