summaryrefslogtreecommitdiff
path: root/src/mongo/db/service_liaison_mongos.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/service_liaison_mongos.cpp')
-rw-r--r--src/mongo/db/service_liaison_mongos.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/mongo/db/service_liaison_mongos.cpp b/src/mongo/db/service_liaison_mongos.cpp
index 2775877ae94..8f687f4f5c7 100644
--- a/src/mongo/db/service_liaison_mongos.cpp
+++ b/src/mongo/db/service_liaison_mongos.cpp
@@ -44,16 +44,35 @@ LogicalSessionIdSet ServiceLiaisonMongos::getActiveOpSessions() const {
invariant(hasGlobalServiceContext());
- // Append any in-use session ids from the global cluster cursor managers.
- auto cursorManager = Grid::get(getGlobalServiceContext())->getCursorManager();
- cursorManager->appendActiveSessions(&activeSessions);
-
+ // Walk through the service context and append lsids for all currently-running ops.
+ for (ServiceContext::LockedClientsCursor cursor(getGlobalServiceContext());
+ Client* client = cursor.next();) {
+
+ stdx::lock_guard<Client> lk(*client);
+ auto clientOpCtx = client->getOperationContext();
+
+ // Ignore clients without currently-running operations
+ if (!clientOpCtx)
+ continue;
+
+ // Append this op ctx's session to our list, if it has one
+ auto lsid = clientOpCtx->getLogicalSessionId();
+ if (lsid) {
+ activeSessions.insert(*lsid);
+ }
+ }
return activeSessions;
}
LogicalSessionIdSet ServiceLiaisonMongos::getOpenCursorSessions() const {
LogicalSessionIdSet openCursorSessions;
+ invariant(hasGlobalServiceContext());
+
+ // Append any in-use session ids from the global cluster cursor managers.
+ auto cursorManager = Grid::get(getGlobalServiceContext())->getCursorManager();
+ cursorManager->appendActiveSessions(&openCursorSessions);
+
return openCursorSessions;
}