summaryrefslogtreecommitdiff
path: root/db/clientcursor.cpp
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2008-12-17 15:47:25 -0500
committerDwight <dmerriman@gmail.com>2008-12-17 15:47:25 -0500
commit752dbb0f45fc6e8e67ceca2626dfc0d2508f73e7 (patch)
tree32ee76e0ded16cbb5d4fa78c82bf69082cc12a3d /db/clientcursor.cpp
parent1d8082574af3844607a882b8d953cd1843235509 (diff)
downloadmongo-752dbb0f45fc6e8e67ceca2626dfc0d2508f73e7.tar.gz
fix linker warnings for vc++
defensive code for cursors abouttodelete
Diffstat (limited to 'db/clientcursor.cpp')
-rw-r--r--db/clientcursor.cpp21
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 )
{