Browse files

fix ScopedDBCOnnectionleak SERVER-1077

  • Loading branch information...
1 parent aff81e6 commit f68e9e023513d01e3c088e015047b6daec62f228 @erh erh committed May 3, 2010
Showing with 8 additions and 4 deletions.
  1. +5 −3 client/connpool.cpp
  2. +3 −1 client/connpool.h
View
8 client/connpool.cpp
@@ -137,9 +137,11 @@ namespace mongo {
}
ScopedDbConnection::~ScopedDbConnection() {
- if ( _conn && ! _conn->isFailed() ) {
- /* see done() comments above for why we log this line */
- log() << "~ScopedDBConnection: _conn != null" << endl;
+ if ( _conn ){
+ if ( ! _conn->isFailed() ) {
+ /* see done() comments above for why we log this line */
+ log() << "~ScopedDBConnection: _conn != null" << endl;
+ }
kill();
}
}
View
4 client/connpool.h
@@ -65,8 +65,10 @@ namespace mongo {
void flush();
DBClientBase *get(const string& host);
void release(const string& host, DBClientBase *c) {
- if ( c->isFailed() )
+ if ( c->isFailed() ){
+ delete c;
return;
+ }
scoped_lock L(_mutex);
_pools[host]->pool.push(c);
}

0 comments on commit f68e9e0

Please sign in to comment.