From 9176cf37e325074cbf6d76f7d6b0f47ac7c35f4e Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Fri, 20 Jun 2014 18:58:29 -0400 Subject: SERVER-13635 Clean up BtreeCursor save/restore. It is now up to the BtreeInterface impl to decide what data it needs to save. Save and restore must *always* be called before/after a yield if you intend to use the cursor again, even if it is at EOF. --- src/mongo/db/exec/count.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/mongo/db/exec/count.cpp') diff --git a/src/mongo/db/exec/count.cpp b/src/mongo/db/exec/count.cpp index 9f2eeaf1a8c..56e8607a611 100644 --- a/src/mongo/db/exec/count.cpp +++ b/src/mongo/db/exec/count.cpp @@ -127,20 +127,18 @@ namespace mongo { } void Count::prepareToYield() { - if (isEOF() || (NULL == _btreeCursor.get())) { return; } + if (_hitEnd || (NULL == _btreeCursor.get())) { return; } - verify(!_btreeCursor->isEOF()); _btreeCursor->savePosition(); - if (!_endCursor->isEOF()) { - _endCursor->savePosition(); - } + _endCursor->savePosition(); } void Count::recoverFromYield() { - if (isEOF() || (NULL == _btreeCursor.get())) { return; } + if (_hitEnd || (NULL == _btreeCursor.get())) { return; } if (!_btreeCursor->restorePosition().isOK()) { _hitEnd = true; + return; } if (_btreeCursor->isEOF()) { @@ -156,11 +154,9 @@ namespace mongo { return; } - if (!_endCursor->isEOF()) { - if (!_endCursor->restorePosition().isOK()) { - _hitEnd = true; - return; - } + if (!_endCursor->restorePosition().isOK()) { + _hitEnd = true; + return; } // If we were EOF when we yielded we don't always want to have _btreeCursor run until -- cgit v1.2.1