From bdcf5dea7c2e7493be7d8fc157e168b77cce7dcc Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 21 May 2015 18:57:10 +0200 Subject: [PATCH] Fix intermittent hang issue in scheduler_tests Don't clear `stopRequested` and `stopWhenEmpty` at the top of `serviceQueue`, as this results in a race condition: on systems under heavy load, some of the threads only get scheduled on the CPU when the other threads have already finished their work. This causes the flags to be cleared post-hoc and thus those threads to wait forever. The potential drawback of this change is that the scheduler cannot be restarted after being stopped (an explicit reset would be needed), but we don't use this functionality anyway. --- src/scheduler.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/scheduler.cpp b/src/scheduler.cpp index 4f1d8be7c..c42eb7244 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -29,8 +29,6 @@ void CScheduler::serviceQueue() { boost::unique_lock lock(newTaskMutex); ++nThreadsServicingQueue; - stopRequested = false; - stopWhenEmpty = false; // newTaskMutex is locked throughout this loop EXCEPT // when the thread is waiting or when the user's function