diff options
author | Aaron <aaron@10gen.com> | 2010-01-12 16:56:29 -0800 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2010-01-12 16:56:29 -0800 |
commit | 81dd7eed519dd1e911ff344c1f098501fa6bdd97 (patch) | |
tree | 0e581353b423b25ee1523c79fc4066442cc987be /db/lasterror.h | |
parent | cf3b8f2468ef1844e38c092b72d53148cd775567 (diff) | |
download | mongo-81dd7eed519dd1e911ff344c1f098501fa6bdd97.tar.gz |
SERVER-531 use correct threading model for disabling lastError
Diffstat (limited to 'db/lasterror.h')
-rw-r--r-- | db/lasterror.h | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/db/lasterror.h b/db/lasterror.h index b119b80cab8..8f687bbf9fc 100644 --- a/db/lasterror.h +++ b/db/lasterror.h @@ -34,6 +34,7 @@ namespace mongo { int nPrev; bool valid; bool overridenById; + bool disabled; void raiseError(int _code , const char *_msg) { reset( true ); code = _code; @@ -59,6 +60,7 @@ namespace mongo { nObjects = 0; nPrev = 1; valid = _valid; + disabled = false; } void appendSelf( BSONObjBuilder &b ); static LastError noError; @@ -66,10 +68,12 @@ namespace mongo { extern class LastErrorHolder { public: - LastErrorHolder() : _id( 0 ), _disabled() {} + LastErrorHolder() : _id( 0 ) {} LastError * get( bool create = false ); + LastError * _get( bool create = false ); // may return a disabled LastError + void reset( LastError * le ); /** @@ -88,10 +92,7 @@ namespace mongo { // used to disable lastError reporting while processing a killCursors message // disable causes get() to return 0. LastError *disableForCommand(); // only call once per command invocation! - void enable() { _disabled = false; } - bool disabled() { return _disabled; } private: - void disable() { _disabled = true; } ThreadLocalValue<int> _id; boost::thread_specific_ptr<LastError> _tl; @@ -101,20 +102,17 @@ namespace mongo { }; static boost::mutex _idsmutex; map<int,Status> _ids; - bool _disabled; } lastError; inline void raiseError(int code , const char *msg) { LastError *le = lastError.get(); if ( le == 0 ) { - if ( lastError.disabled() ) { - log() << "lastError disabled, can't report: " << msg << endl; - } else { - DEV log() << "warning: lastError==0 can't report:" << msg << '\n'; - } - return; + DEV log() << "warning: lastError==0 can't report:" << msg << '\n'; + } else if ( le->disabled ) { + log() << "lastError disabled, can't report: " << msg << endl; + } else { + le->raiseError(code, msg); } - le->raiseError(code, msg); } inline void recordUpdate( bool updatedExisting, int nChanged ) { |