diff options
author | Jason Chan <jason.chan@10gen.com> | 2019-07-17 17:35:05 -0400 |
---|---|---|
committer | Jason Chan <jason.chan@10gen.com> | 2019-07-17 17:35:05 -0400 |
commit | 53e25a0c588a4256a73589ca777cfc4b436d544c (patch) | |
tree | 828e6fc4e7a19b026c6b97ae85eb576df39fc510 /src/mongo/util/fail_point.cpp | |
parent | ff31e4391df93b9186bee6366e194c08173fd1c7 (diff) | |
download | mongo-failpoint_sync.tar.gz |
wrap condition variable waitForConditionOrInterruptNoAssertUntilfailpoint_sync
Diffstat (limited to 'src/mongo/util/fail_point.cpp')
-rw-r--r-- | src/mongo/util/fail_point.cpp | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/mongo/util/fail_point.cpp b/src/mongo/util/fail_point.cpp index 30e1fbe8e8a..8e618a585b0 100644 --- a/src/mongo/util/fail_point.cpp +++ b/src/mongo/util/fail_point.cpp @@ -103,7 +103,7 @@ bool FailPoint::syncEnabled() const { return _syncConfig.enabled; } -void FailPoint::sync() const { +void FailPoint::sync(OperationContext* opCtx) const { if (!syncEnabled()) { return; } @@ -117,20 +117,11 @@ void FailPoint::sync() const { ? Date_t::now() + Seconds(_syncConfig.timeoutSec) : Date_t::max(); while (!isSynced()) { - Milliseconds timeout; - if (deadline == Date_t::max()) { - timeout = Milliseconds::max(); - } else { - auto now = Date_t::now(); - if (deadline <= now) { - timeout = Milliseconds(0); - } else { - timeout = deadline - Date_t::now(); - } - } + auto waitStatus = + opCtx->waitForConditionOrInterruptNoAssertUntil(_condVar, lk, deadline); uassert(ErrorCodes::ExceededTimeLimit, "Timed out waiting for signals", - _condVar.wait_for(lk, timeout.toSystemDuration()) != stdx::cv_status::timeout); + waitStatus.getValue() != stdx::cv_status::timeout); } if (_syncConfig.clearSignals && !_syncConfig.waitFor.empty()) { for (auto& w : _syncConfig.waitFor) { |