summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Studer <greg@10gen.com>2012-04-20 12:28:38 -0400
committerGreg Studer <greg@10gen.com>2012-04-20 12:28:38 -0400
commite51ea6f0893cfe62ae84ff570587b2e4df73a40b (patch)
tree5cd9bd47967f625da0c01eb2b91a0ba366c84d62
parente50b2e242875405f2b52d8757139961243b21b78 (diff)
downloadmongo-e51ea6f0893cfe62ae84ff570587b2e4df73a40b.tar.gz
Revert "SERVER-4680 sendNextBatch logic isn't correct with nonzero batch size"
This reverts commit e50b2e242875405f2b52d8757139961243b21b78.
-rw-r--r--s/cursors.cpp16
-rw-r--r--s/strategy_shard.cpp4
2 files changed, 11 insertions, 9 deletions
diff --git a/s/cursors.cpp b/s/cursors.cpp
index 5957ffcb418..12b3d5e7d2f 100644
--- a/s/cursors.cpp
+++ b/s/cursors.cpp
@@ -82,10 +82,7 @@ namespace mongo {
BufBuilder b(32768);
int num = 0;
-
- // Send more if ntoreturn is 0, or any value > 1 (one is assumed to be a single doc return, with no cursor)
- bool sendMore = ntoreturn == 0 || ntoreturn > 1;
- ntoreturn = abs( ntoreturn );
+ bool sendMore = true;
while ( _cursor->more() ) {
BSONObj o = _cursor->next();
@@ -102,15 +99,20 @@ namespace mongo {
break;
}
- if ( ntoreturn == 0 && _totalSent == 0 && num >= 100 ) {
+ if ( ntoreturn != 0 && ( -1 * num + _totalSent ) == ntoreturn ) {
+ // hard limit - total to send
+ sendMore = false;
+ break;
+ }
+
+ if ( ntoreturn == 0 && _totalSent == 0 && num > 100 ) {
// first batch should be max 100 unless batch size specified
break;
}
}
bool hasMore = sendMore && _cursor->more();
- LOG(5) << "\t hasMore: " << hasMore << " sendMore: " << sendMore << " cursorMore: " << _cursor->more() << " ntoreturn: " << ntoreturn
- << " num: " << num << " wouldSendMoreIfHad: " << sendMore << " id:" << getId() << " totalSent: " << _totalSent << endl;
+ LOG(6) << "\t hasMore:" << hasMore << " wouldSendMoreIfHad: " << sendMore << " id:" << getId() << " totalSent: " << _totalSent << endl;
replyToQuery( 0 , r.p() , r.m() , b.buf() , b.len() , num , _totalSent , hasMore ? getId() : 0 );
_totalSent += num;
diff --git a/s/strategy_shard.cpp b/s/strategy_shard.cpp
index c96a7e1b202..c6b30e7965f 100644
--- a/s/strategy_shard.cpp
+++ b/s/strategy_shard.cpp
@@ -91,10 +91,10 @@ namespace mongo {
}
ShardedClientCursorPtr cc (new ShardedClientCursor( q , cursor ));
- if ( ! cc->sendNextBatch( r, q.ntoreturn ) ) {
+ if ( ! cc->sendNextBatch( r ) ) {
return;
}
- LOG(5) << "storing cursor : " << cc->getId() << endl;
+ LOG(6) << "storing cursor : " << cc->getId() << endl;
cursorCache.store( cc );
}