Skip to content

Commit bdcf5de

Browse files
committed
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.
1 parent 0d862c2 commit bdcf5de

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

src/scheduler.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ void CScheduler::serviceQueue()
2929
{
3030
boost::unique_lock<boost::mutex> lock(newTaskMutex);
3131
++nThreadsServicingQueue;
32-
stopRequested = false;
33-
stopWhenEmpty = false;
3432

3533
// newTaskMutex is locked throughout this loop EXCEPT
3634
// when the thread is waiting or when the user's function

0 commit comments

Comments
 (0)