diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-03-17 14:49:49 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-03-17 14:50:38 -0400 |
commit | 676db17f512e39db5c9997e90ed12956a9b62630 (patch) | |
tree | a5399857e2d4b2dafde3290eb7f7ab53c5d7d47e /client/connpool.cpp | |
parent | c7858afaff8b2eab6638199086cf2a45aff66774 (diff) | |
download | mongo-676db17f512e39db5c9997e90ed12956a9b62630.tar.gz |
standards compliant and leak a list on shutdown to avoid race condition SERVER-2704
Diffstat (limited to 'client/connpool.cpp')
-rw-r--r-- | client/connpool.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/client/connpool.cpp b/client/connpool.cpp index a521699bebe..e80df40790a 100644 --- a/client/connpool.cpp +++ b/client/connpool.cpp @@ -97,6 +97,12 @@ namespace mongo { DBConnectionPool pool; + DBConnectionPool::DBConnectionPool() + : _mutex("DBConnectionPool") , + _name( "dbconnectionpool" ) , + _hooks( new list<DBConnectionHook*>() ) { + } + DBClientBase* DBConnectionPool::_get(const string& ident) { scoped_lock L(_mutex); PoolForHost& p = _pools[ident]; @@ -160,23 +166,23 @@ namespace mongo { } void DBConnectionPool::addHook( DBConnectionHook * hook ) { - _hooks.push_back( hook ); + _hooks->push_back( hook ); } void DBConnectionPool::onCreate( DBClientBase * conn ) { - if ( _hooks.size() == 0 ) + if ( _hooks->size() == 0 ) return; - for ( list<DBConnectionHook*>::iterator i = _hooks.begin(); i != _hooks.end(); i++ ) { + for ( list<DBConnectionHook*>::iterator i = _hooks->begin(); i != _hooks->end(); i++ ) { (*i)->onCreate( conn ); } } void DBConnectionPool::onHandedOut( DBClientBase * conn ) { - if ( _hooks.size() == 0 ) + if ( _hooks->size() == 0 ) return; - for ( list<DBConnectionHook*>::iterator i = _hooks.begin(); i != _hooks.end(); i++ ) { + for ( list<DBConnectionHook*>::iterator i = _hooks->begin(); i != _hooks->end(); i++ ) { (*i)->onHandedOut( conn ); } } |