don't wait on a condition variable if should_run is false

This commit is contained in:
Chris Brannon 2009-06-25 20:33:17 -05:00 committed by William Hubbs
commit d5fd5d69b8

View file

@ -172,7 +172,7 @@ static void request_espeak_stop(void)
pthread_mutex_lock(&queue_guard);
runner_must_stop = 1;
pthread_cond_signal(&runner_awake); /* Wake runner, if necessary. */
while(runner_must_stop == 1)
while(should_run && (runner_must_stop == 1))
pthread_cond_wait(&stop_acknowledged, &queue_guard); /* wait for acknowledgement. */
pthread_mutex_unlock(&queue_guard);
}