summaryrefslogtreecommitdiff
path: root/src/mongo/client/connpool.cpp
diff options
context:
space:
mode:
authorBen Caimano <ben.caimano@mongodb.com>2019-09-17 23:22:19 +0000
committerevergreen <evergreen@mongodb.com>2019-09-17 23:22:19 +0000
commitbc11369435ca51e2ff6897433d00f6b909f6a25f (patch)
tree251653ec8285d798b41846e343e7e414e80ff277 /src/mongo/client/connpool.cpp
parent45aea2495306dd61fab46bd398735bb6aaf7b53a (diff)
downloadmongo-bc11369435ca51e2ff6897433d00f6b909f6a25f.tar.gz
SERVER-42165 Replace uses of stdx::mutex with mongo::Mutex
Diffstat (limited to 'src/mongo/client/connpool.cpp')
-rw-r--r--src/mongo/client/connpool.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/mongo/client/connpool.cpp b/src/mongo/client/connpool.cpp
index 5901f695014..776f8bd6dbd 100644
--- a/src/mongo/client/connpool.cpp
+++ b/src/mongo/client/connpool.cpp
@@ -217,7 +217,7 @@ void PoolForHost::initializeHostName(const std::string& hostName) {
}
}
-void PoolForHost::waitForFreeConnection(int timeout, stdx::unique_lock<stdx::mutex>& lk) {
+void PoolForHost::waitForFreeConnection(int timeout, stdx::unique_lock<Latch>& lk) {
auto condition = [&] { return (numInUse() < _maxInUse || _inShutdown.load()); };
if (timeout > 0) {
@@ -263,7 +263,7 @@ public:
// there are too many connections in this pool to make a new one, block until a
// connection is released.
{
- stdx::unique_lock<stdx::mutex> lk(_this->_mutex);
+ stdx::unique_lock<Latch> lk(_this->_mutex);
PoolForHost& p = _this->_pools[PoolKey(host, timeout)];
if (p.openConnections() >= _this->_maxInUse) {
@@ -307,7 +307,7 @@ DBConnectionPool::DBConnectionPool()
void DBConnectionPool::shutdown() {
if (!_inShutdown.swap(true)) {
- stdx::lock_guard<stdx::mutex> L(_mutex);
+ stdx::lock_guard<Latch> L(_mutex);
for (auto i = _pools.begin(); i != _pools.end(); i++) {
PoolForHost& p = i->second;
p.shutdown();
@@ -319,7 +319,7 @@ DBClientBase* DBConnectionPool::_get(const string& ident, double socketTimeout)
uassert(ErrorCodes::ShutdownInProgress,
"Can't use connection pool during shutdown",
!globalInShutdownDeprecated());
- stdx::lock_guard<stdx::mutex> L(_mutex);
+ stdx::lock_guard<Latch> L(_mutex);
PoolForHost& p = _pools[PoolKey(ident, socketTimeout)];
p.setMaxPoolSize(_maxPoolSize);
p.setSocketTimeout(socketTimeout);
@@ -328,7 +328,7 @@ DBClientBase* DBConnectionPool::_get(const string& ident, double socketTimeout)
}
int DBConnectionPool::openConnections(const string& ident, double socketTimeout) {
- stdx::lock_guard<stdx::mutex> L(_mutex);
+ stdx::lock_guard<Latch> L(_mutex);
PoolForHost& p = _pools[PoolKey(ident, socketTimeout)];
return p.openConnections();
}
@@ -337,7 +337,7 @@ DBClientBase* DBConnectionPool::_finishCreate(const string& ident,
double socketTimeout,
DBClientBase* conn) {
{
- stdx::lock_guard<stdx::mutex> L(_mutex);
+ stdx::lock_guard<Latch> L(_mutex);
PoolForHost& p = _pools[PoolKey(ident, socketTimeout)];
p.setMaxPoolSize(_maxPoolSize);
p.initializeHostName(ident);
@@ -400,13 +400,13 @@ DBClientBase* DBConnectionPool::get(const MongoURI& uri, double socketTimeout) {
}
int DBConnectionPool::getNumAvailableConns(const string& host, double socketTimeout) const {
- stdx::lock_guard<stdx::mutex> L(_mutex);
+ stdx::lock_guard<Latch> L(_mutex);
auto it = _pools.find(PoolKey(host, socketTimeout));
return (it == _pools.end()) ? 0 : it->second.numAvailable();
}
int DBConnectionPool::getNumBadConns(const string& host, double socketTimeout) const {
- stdx::lock_guard<stdx::mutex> L(_mutex);
+ stdx::lock_guard<Latch> L(_mutex);
auto it = _pools.find(PoolKey(host, socketTimeout));
return (it == _pools.end()) ? 0 : it->second.getNumBadConns();
}
@@ -424,7 +424,7 @@ void DBConnectionPool::onRelease(DBClientBase* conn) {
void DBConnectionPool::release(const string& host, DBClientBase* c) {
onRelease(c);
- stdx::unique_lock<stdx::mutex> lk(_mutex);
+ stdx::unique_lock<Latch> lk(_mutex);
PoolForHost& p = _pools[PoolKey(host, c->getSoTimeout())];
p.done(this, c);
@@ -441,7 +441,7 @@ void DBConnectionPool::decrementEgress(const string& host, DBClientBase* c) {
DBConnectionPool::~DBConnectionPool() {
// Do not log in destruction, because global connection pools get
// destroyed after the logging framework.
- stdx::lock_guard<stdx::mutex> L(_mutex);
+ stdx::lock_guard<Latch> L(_mutex);
for (PoolMap::iterator i = _pools.begin(); i != _pools.end(); i++) {
PoolForHost& p = i->second;
p._parentDestroyed = true;
@@ -453,7 +453,7 @@ DBConnectionPool::~DBConnectionPool() {
}
void DBConnectionPool::flush() {
- stdx::lock_guard<stdx::mutex> L(_mutex);
+ stdx::lock_guard<Latch> L(_mutex);
for (PoolMap::iterator i = _pools.begin(); i != _pools.end(); i++) {
PoolForHost& p = i->second;
p.flush();
@@ -461,7 +461,7 @@ void DBConnectionPool::flush() {
}
void DBConnectionPool::clear() {
- stdx::lock_guard<stdx::mutex> L(_mutex);
+ stdx::lock_guard<Latch> L(_mutex);
LOG(2) << "Removing connections on all pools owned by " << _name << endl;
for (PoolMap::iterator iter = _pools.begin(); iter != _pools.end(); ++iter) {
iter->second.clear();
@@ -469,7 +469,7 @@ void DBConnectionPool::clear() {
}
void DBConnectionPool::removeHost(const string& host) {
- stdx::lock_guard<stdx::mutex> L(_mutex);
+ stdx::lock_guard<Latch> L(_mutex);
LOG(2) << "Removing connections from all pools for host: " << host << endl;
for (PoolMap::iterator i = _pools.begin(); i != _pools.end(); ++i) {
const string& poolHost = i->first.ident;
@@ -513,7 +513,7 @@ void DBConnectionPool::onDestroy(DBClientBase* conn) {
void DBConnectionPool::appendConnectionStats(executor::ConnectionPoolStats* stats) const {
{
- stdx::lock_guard<stdx::mutex> lk(_mutex);
+ stdx::lock_guard<Latch> lk(_mutex);
for (PoolMap::const_iterator i = _pools.begin(); i != _pools.end(); ++i) {
if (i->second.numCreated() == 0)
continue;
@@ -581,7 +581,7 @@ bool DBConnectionPool::isConnectionGood(const string& hostName, DBClientBase* co
}
{
- stdx::lock_guard<stdx::mutex> sl(_mutex);
+ stdx::lock_guard<Latch> sl(_mutex);
PoolForHost& pool = _pools[PoolKey(hostName, conn->getSoTimeout())];
if (pool.isBadSocketCreationTime(conn->getSockCreationMicroSec())) {
return false;
@@ -597,7 +597,7 @@ void DBConnectionPool::taskDoWork() {
{
// we need to get the connections inside the lock
// but we can actually delete them outside
- stdx::lock_guard<stdx::mutex> lk(_mutex);
+ stdx::lock_guard<Latch> lk(_mutex);
for (PoolMap::iterator i = _pools.begin(); i != _pools.end(); ++i) {
i->second.getStaleConnections(idleThreshold, toDelete);
}