diff options
| author | Wladimir J. van der Laan <[email protected]> | 2016-11-19 16:18:19 +0100 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2016-11-19 16:18:38 +0100 |
| commit | ce612f17506345527382ec70d6dc398ebe94dbb1 (patch) | |
| tree | 8f09f5be1583b18cdfbee7e54f9ea9ec1e2a8a72 | |
| parent | Merge #9075: Decouple peer-processing-logic from block-connection-logic (#3) (diff) | |
| parent | test: Fix use-after-free in scheduler tests (diff) | |
| download | discoin-ce612f17506345527382ec70d6dc398ebe94dbb1.tar.xz discoin-ce612f17506345527382ec70d6dc398ebe94dbb1.zip | |
Merge #9186: test: Fix use-after-free in scheduler tests
12519bf test: Fix use-after-free in scheduler tests (Wladimir J. van der Laan)
| -rw-r--r-- | src/scheduler.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/scheduler.cpp b/src/scheduler.cpp index 52777b61f..27c03f154 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -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 |