summaryrefslogtreecommitdiff
path: root/src/mongo/client
diff options
context:
space:
mode:
authorMoustafa Maher <m.maher@10gen.com>2021-09-14 21:34:42 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-09-14 22:41:21 +0000
commitb0e9dc9ebdc8b88a33b110542e8d3e9d912b074c (patch)
tree8e115993e39ed26eb957f3c4b841fd43b30ff700 /src/mongo/client
parent9a31793b88af8c10385fd5f5c303e22a37f28249 (diff)
downloadmongo-b0e9dc9ebdc8b88a33b110542e8d3e9d912b074c.tar.gz
SERVER-57823 Open cloning cursors and determining if we are done
Diffstat (limited to 'src/mongo/client')
-rw-r--r--src/mongo/client/fetcher.cpp9
-rw-r--r--src/mongo/client/fetcher.h7
2 files changed, 11 insertions, 5 deletions
diff --git a/src/mongo/client/fetcher.cpp b/src/mongo/client/fetcher.cpp
index 75cbf7f1d0d..4223dbd85ab 100644
--- a/src/mongo/client/fetcher.cpp
+++ b/src/mongo/client/fetcher.cpp
@@ -339,8 +339,11 @@ Status Fetcher::_scheduleGetMore(const BSONObj& cmdObj) {
void Fetcher::_callback(const RemoteCommandCallbackArgs& rcbd, const char* batchFieldName) {
QueryResponse batchData;
- ScopeGuard finishCallbackGuard([this, &batchData] {
- if (batchData.cursorId && !batchData.nss.isEmpty()) {
+ NextAction nextAction = NextAction::kNoAction;
+
+ ScopeGuard finishCallbackGuard([this, &batchData, &nextAction] {
+ if (batchData.cursorId && !batchData.nss.isEmpty() &&
+ nextAction != NextAction::kExitAndKeepCursorAlive) {
_sendKillCursors(batchData.cursorId, batchData.nss);
}
_finishCallback();
@@ -377,8 +380,6 @@ void Fetcher::_callback(const RemoteCommandCallbackArgs& rcbd, const char* batch
_first = false;
}
- NextAction nextAction = NextAction::kNoAction;
-
if (!batchData.cursorId) {
_work(StatusWith<QueryResponse>(batchData), &nextAction, nullptr);
return;
diff --git a/src/mongo/client/fetcher.h b/src/mongo/client/fetcher.h
index 439a201dc88..82ab4f4e83f 100644
--- a/src/mongo/client/fetcher.h
+++ b/src/mongo/client/fetcher.h
@@ -80,7 +80,12 @@ public:
/**
* Represents next steps of fetcher.
*/
- enum class NextAction : int { kInvalid = 0, kNoAction = 1, kGetMore = 2 };
+ enum class NextAction : int {
+ kInvalid = 0,
+ kNoAction = 1,
+ kGetMore = 2,
+ kExitAndKeepCursorAlive = 3
+ };
/**
* Type of a fetcher callback function.