summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/query.cpp20
-rw-r--r--jstests/slowNightly/explain1.js5
2 files changed, 14 insertions, 11 deletions
diff --git a/db/query.cpp b/db/query.cpp
index df09fcec51c..50e2fc385fa 100644
--- a/db/query.cpp
+++ b/db/query.cpp
@@ -435,14 +435,18 @@ namespace mongo {
}
virtual bool prepareToYield() {
- if ( ! _cc ) {
+ if ( _c && !_cc ) {
_cc.reset( new ClientCursor( QueryOption_NoCursorTimeout , _c , _ns.c_str() ) );
}
- return _cc->prepareToYield( _yieldData );
+ if ( _cc ) {
+ return _cc->prepareToYield( _yieldData );
+ }
+ // no active cursor - ok to yield
+ return true;
}
virtual void recoverFromYield() {
- if ( !ClientCursor::recoverFromYield( _yieldData ) ) {
+ if ( _cc && !ClientCursor::recoverFromYield( _yieldData ) ) {
_c.reset();
_cc.reset();
@@ -698,11 +702,15 @@ namespace mongo {
return _findingStartCursor->prepareToYield();
}
else {
- if ( ! _cc ) {
+ if ( _c && !_cc ) {
_cc.reset( new ClientCursor( QueryOption_NoCursorTimeout , _c , _pq.ns() ) );
}
- return _cc->prepareToYield( _yieldData );
+ if ( _cc ) {
+ return _cc->prepareToYield( _yieldData );
+ }
}
+ // no active cursor - ok to yield
+ return true;
}
virtual void recoverFromYield() {
@@ -711,7 +719,7 @@ namespace mongo {
if ( _findingStartCursor.get() ) {
_findingStartCursor->recoverFromYield();
}
- else if ( ! ClientCursor::recoverFromYield( _yieldData ) ) {
+ else if ( _cc && !ClientCursor::recoverFromYield( _yieldData ) ) {
_c.reset();
_cc.reset();
_so.reset();
diff --git a/jstests/slowNightly/explain1.js b/jstests/slowNightly/explain1.js
index c5b3ed28a5d..81baeb6e918 100644
--- a/jstests/slowNightly/explain1.js
+++ b/jstests/slowNightly/explain1.js
@@ -1,8 +1,5 @@
// SERVER-2662 - drop client cursor in a context where query will yield frequently
-// disabled until SERVER-2662 fixed
-if ( false ) {
-
t = db.jstests_slowNightly_explain1;
t.drop();
@@ -18,5 +15,3 @@ s3 = startParallelShell( "t = db.jstests_slowNightly_explain1; for( var i = 0; i
s1();
s2();
s3();
-
-} \ No newline at end of file