summaryrefslogtreecommitdiff
path: root/src/mongo/client/connpool.cpp
diff options
context:
space:
mode:
authorJonathan Reams <jbreams@mongodb.com>2016-11-29 20:01:18 -0500
committerJonathan Reams <jbreams@mongodb.com>2016-12-08 10:44:05 -0500
commitd55eb9d186f3039695a4d710116e79ad04536409 (patch)
treed7eeb820a9365d9266f926969177c05a9413e300 /src/mongo/client/connpool.cpp
parente91795212e7f274db6eb66efd5bbad8f144cdf32 (diff)
downloadmongo-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.cpp21
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;