diff options
author | David Storch <david.storch@10gen.com> | 2015-06-22 12:25:10 -0400 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2015-06-23 14:16:18 -0400 |
commit | b8f0f273d8f2db1aed1974b94c9b18a63656ad48 (patch) | |
tree | ef86771a005eed7dc7d409857f187aba764a0a02 /src/mongo/db/commands/getmore_cmd.cpp | |
parent | edfeb6a9f7a5f30a951c673374e9e058b1886a10 (diff) | |
download | mongo-b8f0f273d8f2db1aed1974b94c9b18a63656ad48.tar.gz |
SERVER-5811 implement the killCursors command for mongod
Implementing the killCursors command in mongos and the mongo shell is further work.
Diffstat (limited to 'src/mongo/db/commands/getmore_cmd.cpp')
-rw-r--r-- | src/mongo/db/commands/getmore_cmd.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp index 23805bf1123..c5f32467c00 100644 --- a/src/mongo/db/commands/getmore_cmd.cpp +++ b/src/mongo/db/commands/getmore_cmd.cpp @@ -52,6 +52,7 @@ #include "mongo/db/repl/oplog.h" #include "mongo/db/service_context.h" #include "mongo/db/stats/counters.h" +#include "mongo/stdx/memory.h" #include "mongo/util/log.h" #include "mongo/util/scopeguard.h" @@ -144,7 +145,9 @@ public: // // 1) Normal cursor: we lock with "ctx" and hold it for the whole getMore. // 2) Cursor owned by global cursor manager: we don't lock anything. These cursors - // don't own any collection state. + // don't own any collection state. These cursors are generated either by the + // listCollections or listIndexes commands, as these special cursor-generating commands + // operate over catalog data rather than targeting the data within a collection. // 3) Agg cursor: we lock with "ctx", then release, then relock with "unpinDBLock" and // "unpinCollLock". This is because agg cursors handle locking internally (hence the // release), but the pin and unpin of the cursor must occur under the collection @@ -160,11 +163,10 @@ public: std::unique_ptr<Lock::CollectionLock> unpinCollLock; CursorManager* cursorManager; - CursorManager* globalCursorManager = CursorManager::getGlobalCursorManager(); - if (globalCursorManager->ownsCursorId(request.cursorid)) { - cursorManager = globalCursorManager; + if (request.nss.isListIndexesCursorNS() || request.nss.isListCollectionsCursorNS()) { + cursorManager = CursorManager::getGlobalCursorManager(); } else { - ctx.reset(new AutoGetCollectionForRead(txn, request.nss)); + ctx = stdx::make_unique<AutoGetCollectionForRead>(txn, request.nss); Collection* collection = ctx->getCollection(); if (!collection) { return appendCommandStatus(result, |