diff options
author | Eliot Horowitz <eliot@10gen.com> | 2012-07-15 22:22:03 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2012-07-27 16:31:12 -0400 |
commit | de0cfcd8de67c52b8206a27b7a5a939e70520051 (patch) | |
tree | 37abfa623e2146385e139406ca7335d2e52f2910 | |
parent | 8e42151eccd3766bd0ad0320340d930ad0cc54ed (diff) | |
download | mongo-de0cfcd8de67c52b8206a27b7a5a939e70520051.tar.gz |
SERVER-6391 - don't sleep if we're a reader,
and call ElapsedTracker::resetLastTime when we're done sleeping
Conflicts:
db/clientcursor.cpp
-rw-r--r-- | db/clientcursor.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/db/clientcursor.cpp b/db/clientcursor.cpp index e803afd459c..52f37cdd47d 100644 --- a/db/clientcursor.cpp +++ b/db/clientcursor.cpp @@ -457,7 +457,9 @@ namespace mongo { if ( yielded ) { *yielded = true; } - return yield( yieldSuggest() , rec ); + bool res = yield( yieldSuggest() , rec ); + _yieldSometimesTracker.resetLastTime(); + return res; } return true; } @@ -467,12 +469,16 @@ namespace mongo { if ( yielded ) { *yielded = true; } - return yield( micros , _recordForYield( need ) ); + bool res = yield( micros , _recordForYield( need ) ); + _yieldSometimesTracker.resetLastTime(); + return res; } return true; } void ClientCursor::staticYield( int micros , const StringData& ns , Record * rec ) { + bool haveReadLock = dbMutex.atLeastReadLocked() && ! dbMutex.isWriteLocked(); + killCurrentOp.checkForInterrupt( false ); { auto_ptr<RWLockRecursive::Shared> lk; @@ -481,10 +487,16 @@ namespace mongo { dbtempreleasecond unlock; if ( unlock.unlocked() ) { - if ( micros == -1 ) - micros = Client::recommendedYieldMicros(); - if ( micros > 0 ) - sleepmicros( micros ); + if ( haveReadLock ) { + // don't sleep with a read lock + } + else { + if ( micros == -1 ) + micros = Client::recommendedYieldMicros(); + if ( micros > 0 ) + sleepmicros( micros ); + } + } else { CurOp * c = cc().curop(); |