diff options
author | Jonathan Reams <jbreams@mongodb.com> | 2016-11-29 20:01:18 -0500 |
---|---|---|
committer | Jonathan Reams <jbreams@mongodb.com> | 2016-12-08 10:44:05 -0500 |
commit | d55eb9d186f3039695a4d710116e79ad04536409 (patch) | |
tree | d7eeb820a9365d9266f926969177c05a9413e300 /src/mongo/client/connpool.cpp | |
parent | e91795212e7f274db6eb66efd5bbad8f144cdf32 (diff) | |
download | mongo-d55eb9d186f3039695a4d710116e79ad04536409.tar.gz |
SERVER-27210 Allow shell to connect to replicasets with ssl=true in URI
Diffstat (limited to 'src/mongo/client/connpool.cpp')
-rw-r--r-- | src/mongo/client/connpool.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/mongo/client/connpool.cpp b/src/mongo/client/connpool.cpp index 8ac32a3386b..7a960dc8d42 100644 --- a/src/mongo/client/connpool.cpp +++ b/src/mongo/client/connpool.cpp @@ -258,6 +258,20 @@ DBClientBase* DBConnectionPool::get(const string& host, double socketTimeout) { return _finishCreate(host, socketTimeout, c); } +DBClientBase* DBConnectionPool::get(const MongoURI& uri, double socketTimeout) { + std::unique_ptr<DBClientBase> c(_get(uri.toString(), socketTimeout)); + if (c) { + onHandedOut(c.get()); + return c.release(); + } + + string errmsg; + c = std::unique_ptr<DBClientBase>(uri.connect(StringData(), errmsg, socketTimeout)); + uassert(40356, _name + ": connect failed " + uri.toString() + " : " + errmsg, c); + + return _finishCreate(uri.toString(), socketTimeout, c.release()); +} + int DBConnectionPool::getNumAvailableConns(const string& host, double socketTimeout) const { stdx::lock_guard<stdx::mutex> L(_mutex); auto it = _pools.find(PoolKey(host, socketTimeout)); @@ -467,6 +481,13 @@ ScopedDbConnection::ScopedDbConnection(const ConnectionString& host, double sock _setSocketTimeout(); } +ScopedDbConnection::ScopedDbConnection(const MongoURI& uri, double socketTimeout) + : _host(uri.toString()), + _conn(globalConnPool.get(uri, socketTimeout)), + _socketTimeout(socketTimeout) { + _setSocketTimeout(); +} + void ScopedDbConnection::done() { if (!_conn) { return; |