diff options
author | Dwight <dmerriman@gmail.com> | 2008-12-17 15:47:25 -0500 |
---|---|---|
committer | Dwight <dmerriman@gmail.com> | 2008-12-17 15:47:25 -0500 |
commit | 752dbb0f45fc6e8e67ceca2626dfc0d2508f73e7 (patch) | |
tree | 32ee76e0ded16cbb5d4fa78c82bf69082cc12a3d /db/clientcursor.cpp | |
parent | 1d8082574af3844607a882b8d953cd1843235509 (diff) | |
download | mongo-752dbb0f45fc6e8e67ceca2626dfc0d2508f73e7.tar.gz |
fix linker warnings for vc++
defensive code for cursors abouttodelete
Diffstat (limited to 'db/clientcursor.cpp')
-rw-r--r-- | db/clientcursor.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/db/clientcursor.cpp b/db/clientcursor.cpp index c8c81cd24bf..04ff705bad8 100644 --- a/db/clientcursor.cpp +++ b/db/clientcursor.cpp @@ -26,6 +26,7 @@ #include "query.h" #include "introspect.h" #include <time.h> +#include "db.h" /* TODO: FIX cleanup of clientCursors when hit the end. (ntoreturn insufficient) */ @@ -35,6 +36,9 @@ CCById clientCursorsById; typedef multimap<DiskLoc, ClientCursor*> ByLoc; ByLoc byLoc; +unsigned byLocSize() { + return byLoc.size(); +} void ClientCursor::setLastLoc(DiskLoc L) { if( L == _lastLoc ) @@ -90,13 +94,24 @@ void aboutToDeleteBucket(const DiskLoc& b) { /* must call this on a delete so we clean up the cursors. */ void aboutToDelete(const DiskLoc& dl) { + ByLoc::iterator j = byLoc.lower_bound(dl); + ByLoc::iterator stop = byLoc.upper_bound(dl); + if( j == stop ) + return; + + assert( dbMutexInfo.isLocked() ); vector<ClientCursor*> toAdvance; - for( ByLoc::iterator i = byLoc.lower_bound(dl); - i != byLoc.upper_bound(dl); ++i ) { - toAdvance.push_back(i->second); + while( 1 ) { + toAdvance.push_back(j->second); + WIN assert( j->first == dl ); + ++j; + if( j == stop ) + break; } + wassert( toAdvance.size() < 5000 ); + for( vector<ClientCursor*>::iterator i = toAdvance.begin(); i != toAdvance.end(); ++i ) { |