mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-12 08:50:01 +00:00
Fix a tricky thread synchronization bug.
If a command ran to completion before the thread calling fifo_add_command woke up, that thread would wait forever for the command to start, never realizing that it had already finished.
This commit is contained in:
@@ -113,7 +113,7 @@ espeak_ng_STATUS fifo_add_command(t_espeak_command *the_command)
|
||||
my_start_is_required = 1;
|
||||
pthread_cond_signal(&my_cond_start_is_required);
|
||||
|
||||
while (!my_command_is_running) {
|
||||
while (my_start_is_required && !my_command_is_running) {
|
||||
if((status = pthread_cond_wait(&my_cond_command_is_running, &my_mutex)) != ENS_OK && errno != EINTR) {
|
||||
pthread_mutex_unlock(&my_mutex);
|
||||
return status;
|
||||
@@ -149,7 +149,7 @@ espeak_ng_STATUS fifo_add_commands(t_espeak_command *command1, t_espeak_command
|
||||
my_start_is_required = 1;
|
||||
pthread_cond_signal(&my_cond_start_is_required);
|
||||
|
||||
while (!my_command_is_running) {
|
||||
while (my_start_is_required && !my_command_is_running) {
|
||||
if((status = pthread_cond_wait(&my_cond_command_is_running, &my_mutex)) != ENS_OK && errno != EINTR) {
|
||||
pthread_mutex_unlock(&my_mutex);
|
||||
return status;
|
||||
|
||||
Reference in New Issue
Block a user