diff options
author | Adam Midvidy <amidvidy@gmail.com> | 2015-11-19 12:06:22 -0500 |
---|---|---|
committer | Adam Midvidy <amidvidy@gmail.com> | 2015-11-19 15:48:35 -0500 |
commit | a6221d1dba72923083af809efb5cd61625d7eee2 (patch) | |
tree | b4fcb5e212a989d083141e0c8e87464b773edc69 /src/mongo/executor/connection_pool.cpp | |
parent | b42f5356a233404a5d77229892ebbd37c24001a6 (diff) | |
download | mongo-a6221d1dba72923083af809efb5cd61625d7eee2.tar.gz |
SERVER-21458 thread request timeout in to ConnectionPool::get in NetworkInterfaceASIO
Diffstat (limited to 'src/mongo/executor/connection_pool.cpp')
-rw-r--r-- | src/mongo/executor/connection_pool.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/mongo/executor/connection_pool.cpp b/src/mongo/executor/connection_pool.cpp index a6b39841826..522bf440c38 100644 --- a/src/mongo/executor/connection_pool.cpp +++ b/src/mongo/executor/connection_pool.cpp @@ -32,6 +32,7 @@ #include "mongo/executor/connection_pool.h" #include "mongo/bson/bsonobjbuilder.h" +#include "mongo/executor/remote_command_request.h" #include "mongo/stdx/memory.h" #include "mongo/util/assert_util.h" #include "mongo/util/log.h" @@ -288,7 +289,12 @@ void ConnectionPool::SpecificPool::getConnection(const HostAndPort& hostAndPort, Milliseconds timeout, stdx::unique_lock<stdx::mutex> lk, GetConnectionCallback cb) { - auto expiration = _parent->_factory->now() + timeout; + // We need some logic here to handle kNoTimeout, which is defined as -1 Milliseconds. If we just + // added the timeout, we would get a time 1MS in the past, which would immediately timeout - the + // exact opposite of what we want. + auto expiration = (timeout == RemoteCommandRequest::kNoTimeout) + ? RemoteCommandRequest::kNoExpirationDate + : _parent->_factory->now() + timeout; _requests.push(make_pair(expiration, std::move(cb))); |