0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00

SERVER-28830 check for closed conn in cursorHandleFromId

The old implementation of DBCommandCursor used when running the shell
with --readMode compatibility calls getConnection(which checks if the
connection has been closed) to construct a DBClientCursor which it
passes to setCursor. The new variant used with --readMode command calls
setCursorHandle with the cursor ID. Check that we aren't closed in the
new variant.
This commit is contained in:
Jason Carey 2018-05-02 16:58:46 -04:00
parent dd45579fef
commit bb2a2ccf26
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,17 @@
(function() {
"use strict";
var testDB = db.getSiblingDB('dbcommand_cursor_throws_on_closed_conn');
testDB.dropDatabase();
var coll = testDB.collection;
var conn = testDB.getMongo();
conn.forceReadMode("commands");
assert.commandWorked(coll.save({}));
var res = assert.commandWorked(testDB.runCommand({
find: coll.getName(),
batchSize: 0,
}));
conn.close();
assert.throws(() => new DBCommandCursor(testDB, res));
}());

View File

@ -530,6 +530,9 @@ void MongoBase::Functions::cursorHandleFromId::call(JSContext* cx, JS::CallArgs
uasserted(ErrorCodes::BadValue, "2nd arg must be a NumberLong");
}
// getConnectionRef verifies that the connection is still open
getConnectionRef(args);
std::string ns = ValueWriter(cx, args.get(0)).toString();
long long cursorId = NumberLongInfo::ToNumberLong(cx, args.get(1));