From 51dec77e2d384c9986164bc7096e82f79660c2b9 Mon Sep 17 00:00:00 2001
From: Pedro Gonnet <gonnet@google.com>
Date: Mon, 21 Mar 2016 21:11:33 +0100
Subject: [PATCH] implement fix suggested by peter.

---
 src/scheduler.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/scheduler.c b/src/scheduler.c
index b2babbde51..f7fef87152 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -1011,6 +1011,7 @@ void scheduler_start(struct scheduler *s, unsigned int mask,
 
   /* Wait for the rewait tasks to have executed. */
   pthread_mutex_lock(&s->sleep_mutex);
+  pthread_cond_broadcast(&s->sleep_cond);
   while (s->waiting > waiting_old) {
     pthread_cond_wait(&s->sleep_cond, &s->sleep_mutex);
   }
@@ -1032,6 +1033,11 @@ void scheduler_start(struct scheduler *s, unsigned int mask,
     }
   }
 
+  /* To be safe, fire of one last sleep_cond in a safe way. */
+  pthread_mutex_lock(&s->sleep_mutex);
+  pthread_cond_broadcast(&s->sleep_cond);
+  pthread_mutex_unlock(&s->sleep_mutex);
+
   // message( "enqueueing tasks took %.3f %s." ,
   // clocks_from_ticks( getticks() - tic ), clocks_getunit());
 }
-- 
GitLab