diff options
Diffstat (limited to 'src/mongo/db/query/find.cpp')
-rw-r--r-- | src/mongo/db/query/find.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/mongo/db/query/find.cpp b/src/mongo/db/query/find.cpp index 74a0de79e36..b44f4040644 100644 --- a/src/mongo/db/query/find.cpp +++ b/src/mongo/db/query/find.cpp @@ -192,9 +192,19 @@ namespace mongo { // This is a read lock. const NamespaceString nss(ns); - scoped_ptr<AutoGetCollectionForRead> ctx(new AutoGetCollectionForRead(txn, nss)); - Collection* collection = ctx->getCollection(); - uassert( 17356, "collection dropped between getMore calls", collection ); + boost::scoped_ptr<AutoGetCollectionForRead> ctx; + + CursorManager* cursorManager; + CursorManager* globalCursorManager = CursorManager::getGlobalCursorManager(); + if (globalCursorManager->ownsCursorId(cursorid)) { + cursorManager = globalCursorManager; + } + else { + ctx.reset(new AutoGetCollectionForRead(txn, nss)); + Collection* collection = ctx->getCollection(); + uassert( 17356, "collection dropped between getMore calls", collection ); + cursorManager = collection->cursorManager(); + } QLOG() << "Running getMore, cursorid: " << cursorid << endl; @@ -211,7 +221,7 @@ namespace mongo { // A pin performs a CC lookup and if there is a CC, increments the CC's pin value so it // doesn't time out. Also informs ClientCursor that there is somebody actively holding the // CC, so don't delete it. - ClientCursorPin ccPin(collection->cursorManager(), cursorid); + ClientCursorPin ccPin(cursorManager, cursorid); ClientCursor* cc = ccPin.c(); // If we're not being called from DBDirectClient we want to associate the RecoveryUnit @@ -240,9 +250,14 @@ namespace mongo { resultFlags = ResultFlag_CursorNotFound; } else { - // Quote: check for spoofing of the ns such that it does not match the one originally - // there for the cursor - uassert(17011, "auth error", str::equals(ns, cc->ns().c_str())); + // Check for spoofing of the ns such that it does not match the one originally + // there for the cursor. + if (globalCursorManager->ownsCursorId(cursorid)) { + // TODO Implement auth check for global cursors. SERVER-16657. + } + else { + uassert(17011, "auth error", str::equals(ns, cc->ns().c_str())); + } *isCursorAuthorized = true; // Restore the RecoveryUnit if we need to. |