summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2014-03-05 17:22:49 -0500
committerMathias Stearn <mathias@10gen.com>2014-03-05 17:34:28 -0500
commit8d43b5cb9949c16452cb8d949c89d94cab9c8bad (patch)
tree98de4a3f88d5e559459fc03b6cd7409e5560ac5f
parentb924044bebc7c7b76eee513473adade189bf3ccd (diff)
downloadmongo-r2.6.0-rc1.tar.gz
SERVER-12878 Delete ClientCursor in agg unless returning a cursor to user.r2.6.0-rc1
-rw-r--r--src/mongo/db/commands/pipeline_command.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/mongo/db/commands/pipeline_command.cpp b/src/mongo/db/commands/pipeline_command.cpp
index 395eb75f74e..3926026404f 100644
--- a/src/mongo/db/commands/pipeline_command.cpp
+++ b/src/mongo/db/commands/pipeline_command.cpp
@@ -341,15 +341,22 @@ namespace {
}
try {
+ // Unless set to true, the ClientCursor created above will be deleted on block exit.
+ bool keepCursor = false;
+
+ // If both explain and cursor are specified, explain wins.
if (pPipeline->isExplain()) {
result << "stages" << Value(pPipeline->writeExplainOps());
}
else if (isCursorCommand(cmdObj)) {
handleCursorCommand(ns, pin.get(), runner, cmdObj, result);
+ keepCursor = true;
}
else {
pPipeline->run(result);
}
+
+ if (!keepCursor && pin) pin->deleteUnderlying();
}
catch (...) {
// Clean up cursor on way out of scope.