summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgregs <greg@10gen.com>2011-10-20 15:48:29 -0400
committergregs <greg@10gen.com>2011-10-20 15:48:29 -0400
commit85902e0e826ba543f9ea6021e0d370fcc6dd6854 (patch)
tree95c55f49c862df63b59af0a764e467b9693acf6d
parent58a3ee1f9e39877ffee65564697c43ac647b001d (diff)
downloadmongo-85902e0e826ba543f9ea6021e0d370fcc6dd6854.tar.gz
backport of fix for cursor timeout iteration, from jira discussion SERVER-3996
-rw-r--r--s/cursors.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/s/cursors.cpp b/s/cursors.cpp
index cf2735b1748..eb445762bef 100644
--- a/s/cursors.cpp
+++ b/s/cursors.cpp
@@ -265,13 +265,16 @@ namespace mongo {
void CursorCache::doTimeouts() {
long long now = Listener::getElapsedTimeMillis();
scoped_lock lk( _mutex );
- for ( MapSharded::iterator i=_cursors.begin(); i!=_cursors.end(); ++i ) {
+ MapSharded::iterator i=_cursors.begin();
+ while ( i!=_cursors.end() ) {
+
long long idleFor = i->second->idleTime( now );
if ( idleFor < TIMEOUT ) {
+ ++i;
continue;
}
log() << "killing old cursor " << i->second->getId() << " idle for: " << idleFor << "ms" << endl; // TODO: make log(1)
- _cursors.erase( i );
+ _cursors.erase( i++ );
}
}