diff options
author | Jonathan Reams <jbreams@mongodb.com> | 2019-01-16 11:46:03 -0500 |
---|---|---|
committer | Jonathan Reams <jbreams@mongodb.com> | 2019-01-23 17:02:16 -0500 |
commit | c1b72f76bee602cd915bc6ea91bdcef10bd0c707 (patch) | |
tree | 374edbdb9c98344ad9a0543bb1d04633a045e3e7 /src/mongo/executor/connection_pool_tl.cpp | |
parent | e7b1c689b632610399ab716a98f125605dd8a11c (diff) | |
download | mongo-c1b72f76bee602cd915bc6ea91bdcef10bd0c707.tar.gz |
SERVER-34260 Move bookkeeping functions into ConnectionInterface
Diffstat (limited to 'src/mongo/executor/connection_pool_tl.cpp')
-rw-r--r-- | src/mongo/executor/connection_pool_tl.cpp | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/src/mongo/executor/connection_pool_tl.cpp b/src/mongo/executor/connection_pool_tl.cpp index 344fcac81cc..14c73d50cba 100644 --- a/src/mongo/executor/connection_pool_tl.cpp +++ b/src/mongo/executor/connection_pool_tl.cpp @@ -115,12 +115,8 @@ void TLTimer::cancelTimeout() { _timer->cancel(); } -void TLConnection::indicateSuccess() { - _status = Status::OK(); -} - -void TLConnection::indicateFailure(Status status) { - _status = std::move(status); +Date_t TLTimer::now() { + return _reactor->now(); } const HostAndPort& TLConnection::getHostAndPort() const { @@ -139,20 +135,6 @@ AsyncDBClient* TLConnection::client() { return _client.get(); } -void TLConnection::indicateUsed() { - // It is illegal to attempt to use a connection after calling indicateFailure(). - invariant(_status.isOK() || _status == ConnectionPool::kConnectionStateUnknown); - _lastUsed = _reactor->now(); -} - -Date_t TLConnection::getLastUsed() const { - return _lastUsed; -} - -const Status& TLConnection::getStatus() const { - return _status; -} - void TLConnection::setTimeout(Milliseconds timeout, TimeoutCallback cb) { auto anchor = shared_from_this(); _timer->setTimeout(timeout, [ cb = std::move(cb), anchor = std::move(anchor) ] { cb(); }); @@ -292,10 +274,6 @@ void TLConnection::setup(Milliseconds timeout, SetupCallback cb) { LOG(2) << "Finished connection setup."; } -void TLConnection::resetToUnknown() { - _status = ConnectionPool::kConnectionStateUnknown; -} - void TLConnection::refresh(Milliseconds timeout, RefreshCallback cb) { auto anchor = shared_from_this(); @@ -309,10 +287,10 @@ void TLConnection::refresh(Milliseconds timeout, RefreshCallback cb) { return; } - _status = {ErrorCodes::HostUnreachable, "Timed out refreshing host"}; + indicateFailure({ErrorCodes::HostUnreachable, "Timed out refreshing host"}); _client->cancel(); - handler->promise.setError(_status); + handler->promise.setError(getStatus()); }); _client @@ -328,17 +306,18 @@ void TLConnection::refresh(Milliseconds timeout, RefreshCallback cb) { cancelTimeout(); - _status = status; if (status.isOK()) { + indicateSuccess(); handler->promise.emplaceValue(); } else { + indicateFailure(status); handler->promise.setError(status); } }); } -size_t TLConnection::getGeneration() const { - return _generation; +Date_t TLConnection::now() { + return _reactor->now(); } void TLConnection::cancelAsync() { |