summaryrefslogtreecommitdiff
path: root/src/mongo/client
diff options
context:
space:
mode:
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.