summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorBen Caimano <ben.caimano@mongodb.com>2020-01-21 20:37:41 +0000
committerevergreen <evergreen@mongodb.com>2020-01-21 20:37:41 +0000
commit685afc7262c35f71cc04ceb0819a3a90f06c95bb (patch)
treef6734b456ef4fab5884fd55d72b2eb35b5fa77da /src/mongo
parentb7846ff4dceec36e344b0f87c48783dffa2c6a32 (diff)
downloadmongo-685afc7262c35f71cc04ceb0819a3a90f06c95bb.tar.gz
SERVER-45593 Use SystemClockSource for mock path waitForConditionUntil()
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/util/clock_source.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/mongo/util/clock_source.cpp b/src/mongo/util/clock_source.cpp
index cd3da75e9c9..00f1a6d32c5 100644
--- a/src/mongo/util/clock_source.cpp
+++ b/src/mongo/util/clock_source.cpp
@@ -31,6 +31,7 @@
#include "mongo/platform/basic.h"
#include "mongo/platform/mutex.h"
#include "mongo/stdx/thread.h"
+#include "mongo/util/system_clock_source.h"
#include "mongo/util/waitable.h"
namespace mongo {
@@ -50,8 +51,8 @@ stdx::cv_status ClockSource::waitForConditionUntil(stdx::condition_variable& cv,
// The rest of this function only runs during testing, when the clock source is virtualized and
// does not track the system clock.
- auto currentTime = now();
- if (deadline <= currentTime) {
+ auto testNow = now();
+ if (deadline <= testNow) {
return stdx::cv_status::timeout;
}
@@ -84,7 +85,14 @@ stdx::cv_status ClockSource::waitForConditionUntil(stdx::condition_variable& cv,
// This is a wait_until because theoretically setAlarm could run out of line before this cv
// joins the wait list. Then it could completely miss the notification and block until a lucky
// renotify or spurious wakeup.
- Waitable::wait_until(waitable, this, cv, bla, currentTime + kMaxTimeoutForArtificialClocks);
+ auto systemClockSource = SystemClockSource::get();
+ invariant(this != systemClockSource);
+
+ Waitable::wait_until(waitable,
+ systemClockSource,
+ cv,
+ bla,
+ systemClockSource->now() + kMaxTimeoutForArtificialClocks);
stdx::lock_guard infoLk(alarmInfo->mutex);
alarmInfo->cv = nullptr;