diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-09-14 14:31:46 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-09-14 14:31:46 -0400 |
commit | 11ee78fc03529dde9b47405db65b1148738e33f4 (patch) | |
tree | b6ede61536c509ba4f95ca81c6f2f7ba9710e179 | |
parent | 3b5b0caee9acb94f1a5266587213163945cc44a5 (diff) | |
download | mongo-11ee78fc03529dde9b47405db65b1148738e33f4.tar.gz |
don't complain about ScopedDBConnection if the underlying connection failed
-rw-r--r-- | client/connpool.h | 4 | ||||
-rw-r--r-- | client/dbclient.h | 8 | ||||
-rw-r--r-- | db/instance.h | 3 |
3 files changed, 13 insertions, 2 deletions
diff --git a/client/connpool.h b/client/connpool.h index 4dde01f3d7d..d1a1bae22db 100644 --- a/client/connpool.h +++ b/client/connpool.h @@ -62,6 +62,8 @@ namespace mongo { void flush(); DBClientBase *get(const string& host); void release(const string& host, DBClientBase *c) { + if ( c->isFailed() ) + return; boostlock L(poolMutex); pools[host]->pool.push(c); } @@ -123,7 +125,7 @@ namespace mongo { } ~ScopedDbConnection() { - if ( _conn ) { + if ( _conn && ! _conn->isFailed() ) { /* see done() comments above for why we log this line */ log() << "~ScopedDBConnection: _conn != null" << endl; kill(); diff --git a/client/dbclient.h b/client/dbclient.h index 86a56e0b51c..b0a19193717 100644 --- a/client/dbclient.h +++ b/client/dbclient.h @@ -611,6 +611,8 @@ namespace mongo { resetIndexCache(); return ret; } + + virtual bool isFailed() const = 0; private: set<string> _seenIndexes; @@ -801,7 +803,11 @@ namespace mongo { virtual void say( Message &toSend ) { assert(false); } virtual void sayPiggyBack( Message &toSend ) { assert(false); } virtual void checkResponse( const char *data, int nReturned ) { assert(false); } - + + bool isFailed() const { + // TODO: this really should check isFailed on current master as well + return master > NotSetR; + } }; diff --git a/db/instance.h b/db/instance.h index dfb6d87077e..0e0d1f4628f 100644 --- a/db/instance.h +++ b/db/instance.h @@ -106,6 +106,9 @@ namespace mongo { // --- local client --- class DBDirectClient : public DBClientBase { + virtual bool isFailed() const { + return false; + } virtual string toString() { return "DBDirectClient"; } |