diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-05-18 11:08:41 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-05-18 11:09:45 -0400 |
commit | a852279bc770ea0594bc799ef14ddca4572944a9 (patch) | |
tree | bf52b7890a21ad723306c715b894b38e0ae8e5f7 | |
parent | decf327ef50584a0a55f3718c55713b130362552 (diff) | |
download | mongo-a852279bc770ea0594bc799ef14ddca4572944a9.tar.gz |
fix locking and comment
-rw-r--r-- | s/d_migrate.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/s/d_migrate.cpp b/s/d_migrate.cpp index b5198035692..bc897e7b87d 100644 --- a/s/d_migrate.cpp +++ b/s/d_migrate.cpp @@ -501,9 +501,10 @@ namespace mongo { allocSize = std::min(BSONObjMaxUserSize, (int)((12 + d->averageObjectSize()) * _cloneLocs.size())); } BSONArrayBuilder a (allocSize); - - bool keepGoing = true; - while (keepGoing && !_cloneLocs.empty()){ + + while ( 1 ) { + bool filledBuffer = false; + readlock l( _ns ); Client::Context ctx( _ns ); @@ -518,7 +519,7 @@ namespace mongo { // use the builder size instead of accumulating 'o's size so that we take into consideration // the overhead of BSONArray indices if ( a.len() + o.objsize() + 1024 > BSONObjMaxUserSize ) { - keepGoing = false; // break out of outer while loop + filledBuffer = true; // break out of outer while loop break; } @@ -526,6 +527,9 @@ namespace mongo { } _cloneLocs.erase( _cloneLocs.begin() , i ); + + if ( _cloneLocs.empty() || filledBuffer ) + break; } result.appendArray( "objects" , a.arr() ); @@ -561,8 +565,8 @@ namespace mongo { BSONObj _max; // disk locs yet to be transferred from here to the other side - // no locking needed because build by 1 thread in a read lock - // depleted by 1 thread in a read lock + // no locking needed because built initially by 1 thread in a read lock + // emptied by 1 thread in a read lock // updates applied by 1 thread in a write lock set<DiskLoc> _cloneLocs; |