summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/util/fail_point.cpp6
-rw-r--r--src/mongo/util/fail_point.h19
-rw-r--r--src/mongo/util/fail_point_test.cpp11
3 files changed, 18 insertions, 18 deletions
diff --git a/src/mongo/util/fail_point.cpp b/src/mongo/util/fail_point.cpp
index 8127576a0eb..84a1029bc38 100644
--- a/src/mongo/util/fail_point.cpp
+++ b/src/mongo/util/fail_point.cpp
@@ -115,11 +115,11 @@ auto FailPoint::waitForTimesEntered(EntryCountT targetTimesEntered) const noexce
return timesEntered;
}
-auto FailPoint::waitForTimesEntered(OperationContext* opCtx, EntryCountT targetTimesEntered) const
- -> EntryCountT {
+auto FailPoint::waitForTimesEntered(Interruptible* interruptible,
+ EntryCountT targetTimesEntered) const -> EntryCountT {
auto timesEntered = _timesEntered.load();
for (; timesEntered < targetTimesEntered; timesEntered = _timesEntered.load()) {
- opCtx->sleepFor(kWaitGranularity);
+ interruptible->sleepFor(kWaitGranularity);
};
return timesEntered;
}
diff --git a/src/mongo/util/fail_point.h b/src/mongo/util/fail_point.h
index c7a5f547b35..7467ce4d67a 100644
--- a/src/mongo/util/fail_point.h
+++ b/src/mongo/util/fail_point.h
@@ -35,11 +35,11 @@
#include "mongo/base/status.h"
#include "mongo/base/status_with.h"
#include "mongo/db/jsobj.h"
-#include "mongo/db/operation_context.h"
#include "mongo/platform/atomic_word.h"
#include "mongo/platform/mutex.h"
#include "mongo/stdx/unordered_map.h"
#include "mongo/util/duration.h"
+#include "mongo/util/interruptible.h"
namespace mongo {
@@ -272,11 +272,11 @@ public:
EntryCountT waitForTimesEntered(EntryCountT targetTimesEntered) const noexcept;
/**
- * Like `waitForTimesEntered`, but interruptible via the `opCtx->sleepFor` mechanism. See
- * `mongo::Interruptible::sleepFor` (Interruptible is a base class of
- * OperationContext).
+ * Like `waitForTimesEntered`, but interruptible via the `interruptible->sleepFor` mechanism.
+ * See `mongo::Interruptible::sleepFor`.
*/
- EntryCountT waitForTimesEntered(OperationContext* opCtx, EntryCountT targetTimesEntered) const;
+ EntryCountT waitForTimesEntered(Interruptible* interruptible,
+ EntryCountT targetTimesEntered) const;
/**
* @returns a BSON object showing the current mode and data stored.
@@ -338,14 +338,13 @@ public:
}
/**
- * Like `pauseWhileSet`, but interruptible via the `opCtx->sleepFor` mechanism. See
- * `mongo::Interruptible::sleepFor` (Interruptible is a base class of
- * OperationContext).
+ * Like `pauseWhileSet`, but interruptible via the `interruptible->sleepFor` mechanism. See
+ * `mongo::Interruptible::sleepFor`.
*/
- void pauseWhileSet(OperationContext* opCtx) {
+ void pauseWhileSet(Interruptible* interruptible) {
for (auto entryMode = kFirstTimeEntered; MONGO_unlikely(shouldFail(entryMode));
entryMode = kEnteredAlready) {
- opCtx->sleepFor(Milliseconds(100));
+ interruptible->sleepFor(Milliseconds(100));
}
}
diff --git a/src/mongo/util/fail_point_test.cpp b/src/mongo/util/fail_point_test.cpp
index eaa521d7d72..26b051fb7dc 100644
--- a/src/mongo/util/fail_point_test.cpp
+++ b/src/mongo/util/fail_point_test.cpp
@@ -441,9 +441,9 @@ namespace mongo {
/**
* Runs the given function with an operation context that has a deadline and asserts that
- * the function is interruptable.
+ * the function is interruptible.
*/
-void assertFunctionInterruptable(std::function<void(OperationContext* opCtx)> f) {
+void assertFunctionInterruptable(std::function<void(Interruptible* interruptible)> f) {
const auto service = ServiceContext::make();
const std::shared_ptr<ClockSourceMock> mockClock = std::make_shared<ClockSourceMock>();
service->setFastClockSource(std::make_unique<SharedClockSourceAdapter>(mockClock));
@@ -467,7 +467,7 @@ TEST(FailPoint, PauseWhileSetInterruptibility) {
failPoint.setMode(FailPoint::alwaysOn);
assertFunctionInterruptable(
- [&failPoint](OperationContext* opCtx) { failPoint.pauseWhileSet(opCtx); });
+ [&failPoint](Interruptible* interruptible) { failPoint.pauseWhileSet(interruptible); });
failPoint.setMode(FailPoint::off);
}
@@ -476,8 +476,9 @@ TEST(FailPoint, WaitForFailPointTimeout) {
FailPoint failPoint;
failPoint.setMode(FailPoint::alwaysOn);
- assertFunctionInterruptable(
- [&failPoint](OperationContext* opCtx) { failPoint.waitForTimesEntered(opCtx, 1); });
+ assertFunctionInterruptable([&failPoint](Interruptible* interruptible) {
+ failPoint.waitForTimesEntered(interruptible, 1);
+ });
failPoint.setMode(FailPoint::off);
}