summaryrefslogtreecommitdiff
path: root/client/connpool.cpp
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2011-12-15 09:35:47 +0100
committerAntonin Kral <a.kral@bobek.cz>2011-12-15 09:35:47 +0100
commitf0d9a01bccdaeb466c12c92057914bbfef59526c (patch)
tree7679efa1f0daf7d1d906882a15dc77af6b7aef32 /client/connpool.cpp
parent5d342a758c6095b4d30aba0750b54f13b8916f51 (diff)
downloadmongodb-f0d9a01bccdaeb466c12c92057914bbfef59526c.tar.gz
Imported Upstream version 2.0.2
Diffstat (limited to 'client/connpool.cpp')
-rw-r--r--client/connpool.cpp40
1 files changed, 29 insertions, 11 deletions
diff --git a/client/connpool.cpp b/client/connpool.cpp
index 2d7c37b..94ce4ec 100644
--- a/client/connpool.cpp
+++ b/client/connpool.cpp
@@ -38,7 +38,7 @@ namespace mongo {
void PoolForHost::done( DBConnectionPool * pool, DBClientBase * c ) {
if ( _pool.size() >= _maxPerHost ) {
- pool->onDestory( c );
+ pool->onDestroy( c );
delete c;
}
else {
@@ -55,7 +55,7 @@ namespace mongo {
_pool.pop();
if ( ! sc.ok( now ) ) {
- pool->onDestory( sc.conn );
+ pool->onDestroy( sc.conn );
delete sc.conn;
continue;
}
@@ -145,9 +145,15 @@ namespace mongo {
PoolForHost& p = _pools[PoolKey(host,socketTimeout)];
p.createdOne( conn );
}
-
- onCreate( conn );
- onHandedOut( conn );
+
+ try {
+ onCreate( conn );
+ onHandedOut( conn );
+ }
+ catch ( std::exception& e ) {
+ delete conn;
+ throw;
+ }
return conn;
}
@@ -155,7 +161,13 @@ namespace mongo {
DBClientBase* DBConnectionPool::get(const ConnectionString& url, double socketTimeout) {
DBClientBase * c = _get( url.toString() , socketTimeout );
if ( c ) {
- onHandedOut( c );
+ try {
+ onHandedOut( c );
+ }
+ catch ( std::exception& e ) {
+ delete c;
+ throw;
+ }
return c;
}
@@ -169,7 +181,13 @@ namespace mongo {
DBClientBase* DBConnectionPool::get(const string& host, double socketTimeout) {
DBClientBase * c = _get( host , socketTimeout );
if ( c ) {
- onHandedOut( c );
+ try {
+ onHandedOut( c );
+ }
+ catch ( std::exception& e ) {
+ delete c;
+ throw;
+ }
return c;
}
@@ -185,7 +203,7 @@ namespace mongo {
void DBConnectionPool::release(const string& host, DBClientBase *c) {
if ( c->isFailed() ) {
- onDestory( c );
+ onDestroy( c );
delete c;
return;
}
@@ -228,12 +246,12 @@ namespace mongo {
}
}
- void DBConnectionPool::onDestory( DBClientBase * conn ) {
+ void DBConnectionPool::onDestroy( DBClientBase * conn ) {
if ( _hooks->size() == 0 )
return;
for ( list<DBConnectionHook*>::iterator i = _hooks->begin(); i != _hooks->end(); i++ ) {
- (*i)->onDestory( conn );
+ (*i)->onDestroy( conn );
}
}
@@ -357,7 +375,7 @@ namespace mongo {
for ( size_t i=0; i<toDelete.size(); i++ ) {
try {
- onDestory( toDelete[i] );
+ onDestroy( toDelete[i] );
delete toDelete[i];
}
catch ( ... ) {