Browse Source

Merge #9186: test: Fix use-after-free in scheduler tests

12519bf test: Fix use-after-free in scheduler tests (Wladimir J. van der Laan)
0.14
Wladimir J. van der Laan 8 years ago
parent
commit
ce612f1750
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 7
      src/scheduler.cpp

7
src/scheduler.cpp

@ -54,9 +54,10 @@ void CScheduler::serviceQueue() @@ -54,9 +54,10 @@ void CScheduler::serviceQueue()
#else
// 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()) {
boost::chrono::system_clock::time_point timeToWaitFor = taskQueue.begin()->first;
if (newTaskScheduled.wait_until<>(lock, timeToWaitFor) == boost::cv_status::timeout)
break; // Exit loop after timeout, it means we reached the time of the event
}
#endif
// If there are multiple threads, the queue can empty while we're waiting (another

Loading…
Cancel
Save