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:
parent
f4ea64b9e9
commit
b20e61fe65
@ -37,7 +37,12 @@ namespace mongo {
|
||||
}
|
||||
|
||||
void PoolForHost::done( DBClientBase * c ) {
|
||||
_pool.push(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;
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user