From daf9ed98a1473fab812d565036c0060dabc7a3b3 Mon Sep 17 00:00:00 2001 From: Taylor Hornby Date: Thu, 11 Jun 2020 12:27:45 -0600 Subject: [PATCH] Fix bug in CScheduler --- src/scheduler.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/scheduler.cpp b/src/scheduler.cpp index ecd904cde..44bc57ca3 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -40,9 +40,12 @@ void CScheduler::serviceQueue() // Some boost versions have a conflicting overload of wait_until that returns void. // Explicitly use a template here to avoid hitting that overload. - while (!shouldStop() && !taskQueue.empty() && - newTaskScheduled.wait_until<>(lock, taskQueue.begin()->first) != boost::cv_status::timeout) { - // Keep waiting until timeout + while (!shouldStop() && !taskQueue.empty()) + { + auto copy = taskQueue.begin()->first; + if (newTaskScheduled.wait_until<>(lock, copy) == boost::cv_status::timeout) { + break; + } } // If there are multiple threads, the queue can empty while we're waiting (another