summaryrefslogtreecommitdiff
path: root/src/mongo/db/kill_sessions_common.h
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2019-01-30 14:23:54 -0500
committerDavid Storch <david.storch@10gen.com>2019-01-31 08:31:49 -0500
commit5ee0b3805e9116bf0f4655d5ee5cd5b108e7a7e4 (patch)
tree13c1b78a5b03c6d2788228d6081fef096eb179d0 /src/mongo/db/kill_sessions_common.h
parent4b55effde2d01fa84141f02203a0433a6a4d58f2 (diff)
downloadmongo-5ee0b3805e9116bf0f4655d5ee5cd5b108e7a7e4.tar.gz
SERVER-39065 Delete withCursorManager() and visitAllCursorManagers().
Diffstat (limited to 'src/mongo/db/kill_sessions_common.h')
-rw-r--r--src/mongo/db/kill_sessions_common.h27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/mongo/db/kill_sessions_common.h b/src/mongo/db/kill_sessions_common.h
index 255ac6cde86..9ef2c64c55c 100644
--- a/src/mongo/db/kill_sessions_common.h
+++ b/src/mongo/db/kill_sessions_common.h
@@ -81,13 +81,17 @@ private:
* two types share no code, but do share enough shape to re-use some boilerplate.
*/
template <typename Eraser>
-class KillSessionsCursorManagerVisitor {
+class KillCursorsBySessionAdaptor {
public:
- KillSessionsCursorManagerVisitor(OperationContext* opCtx,
- const SessionKiller::Matcher& matcher,
- Eraser&& eraser)
+ KillCursorsBySessionAdaptor(OperationContext* opCtx,
+ const SessionKiller::Matcher& matcher,
+ Eraser&& eraser)
: _opCtx(opCtx), _matcher(matcher), _cursorsKilled(0), _eraser(eraser) {}
+ /**
+ * Kills cursors in 'mgr' which belong to a session matching the SessionKilled::Matcher with
+ * which this adaptor was constructed.
+ */
template <typename Mgr>
void operator()(Mgr& mgr) {
LogicalSessionIdSet activeSessions;
@@ -110,6 +114,10 @@ public:
}
}
+ /**
+ * Returns an OK status if no errors were encountered during cursor killing, or a non-OK status
+ * summarizing any errors encountered.
+ */
Status getStatus() const {
if (_failures.empty()) {
return Status::OK();
@@ -126,6 +134,9 @@ public:
<< _failures.back().reason());
}
+ /**
+ * Returns the number of cursors killed by operator().
+ */
int getCursorsKilled() const {
return _cursorsKilled;
}
@@ -139,10 +150,10 @@ private:
};
template <typename Eraser>
-auto makeKillSessionsCursorManagerVisitor(OperationContext* opCtx,
- const SessionKiller::Matcher& matcher,
- Eraser&& eraser) {
- return KillSessionsCursorManagerVisitor<std::decay_t<Eraser>>{
+auto makeKillCursorsBySessionAdaptor(OperationContext* opCtx,
+ const SessionKiller::Matcher& matcher,
+ Eraser&& eraser) {
+ return KillCursorsBySessionAdaptor<std::decay_t<Eraser>>{
opCtx, matcher, std::forward<Eraser>(eraser)};
}