0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

cap connections in connection pool stack SERVER-2687 180

This commit is contained in:
Eliot Horowitz 2011-03-05 18:11:04 -05:00
parent f4ea64b9e9
commit b20e61fe65
2 changed files with 13 additions and 1 deletions

View File

@ -37,8 +37,13 @@ namespace mongo {
}
void PoolForHost::done( DBClientBase * c ) {
if ( _pool.size() >= _maxPerHost ) {
delete c;
}
else {
_pool.push(c);
}
}
DBClientBase * PoolForHost::get() {
@ -86,6 +91,8 @@ namespace mongo {
_created++;
}
unsigned PoolForHost::_maxPerHost = 50;
// ------ DBConnectionPool ------
DBConnectionPool pool;

View File

@ -57,6 +57,9 @@ namespace mongo {
void done( DBClientBase * c );
void flush();
static void setMaxPerHost( unsigned max ) { _maxPerHost = max; }
static unsigned getMaxPerHost() { return _maxPerHost; }
private:
struct StoredConnection {
@ -71,6 +74,8 @@ namespace mongo {
std::stack<StoredConnection> _pool;
long long _created;
ConnectionString::ConnectionType _type;
static unsigned _maxPerHost;
};
class DBConnectionHook {