diff options
Diffstat (limited to 'src/mongo/util')
-rw-r--r-- | src/mongo/util/fail_point.cpp | 14 | ||||
-rw-r--r-- | src/mongo/util/fail_point.h | 7 |
2 files changed, 7 insertions, 14 deletions
diff --git a/src/mongo/util/fail_point.cpp b/src/mongo/util/fail_point.cpp index 84a1029bc38..c0a28ddb3ac 100644 --- a/src/mongo/util/fail_point.cpp +++ b/src/mongo/util/fail_point.cpp @@ -108,20 +108,16 @@ auto FailPoint::setMode(Mode mode, ValType val, BSONObj extra) -> EntryCountT { } auto FailPoint::waitForTimesEntered(EntryCountT targetTimesEntered) const noexcept -> EntryCountT { - auto timesEntered = _timesEntered.load(); - for (; timesEntered < targetTimesEntered; timesEntered = _timesEntered.load()) { - sleepmillis(duration_cast<Milliseconds>(kWaitGranularity).count()); - }; - return timesEntered; + return waitForTimesEntered(Interruptible::notInterruptible(), targetTimesEntered); } auto FailPoint::waitForTimesEntered(Interruptible* interruptible, EntryCountT targetTimesEntered) const -> EntryCountT { - auto timesEntered = _timesEntered.load(); - for (; timesEntered < targetTimesEntered; timesEntered = _timesEntered.load()) { + while (true) { + if (auto entries = _timesEntered.load(); entries >= targetTimesEntered) + return entries; interruptible->sleepFor(kWaitGranularity); - }; - return timesEntered; + } } const BSONObj& FailPoint::_getData() const { diff --git a/src/mongo/util/fail_point.h b/src/mongo/util/fail_point.h index 7467ce4d67a..5322fad8b67 100644 --- a/src/mongo/util/fail_point.h +++ b/src/mongo/util/fail_point.h @@ -326,15 +326,12 @@ public: } /** - * Take 100msec pauses for as long as the FailPoint is active. + * Take 'kWaitGranularity' pauses for as long as the FailPoint is active. * This calls `shouldFail()` with kFirstTimeEntered once and with kEnteredAlready thereafter, so * affects FailPoint counters once. */ void pauseWhileSet() { - for (auto entryMode = kFirstTimeEntered; MONGO_unlikely(shouldFail(entryMode)); - entryMode = kEnteredAlready) { - sleepmillis(100); - } + pauseWhileSet(Interruptible::notInterruptible()); } /** |