From f052e0bf16adcc49ccded3534eb8a132916a8418 Mon Sep 17 00:00:00 2001 From: Jonathan Reams Date: Wed, 21 Jun 2017 12:15:56 -0400 Subject: [PATCH] SERVER-29769 Only erase session if session is valid after accept --- src/mongo/transport/session_asio.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/mongo/transport/session_asio.h b/src/mongo/transport/session_asio.h index 42b49cecd049d..9586118093c7a 100644 --- a/src/mongo/transport/session_asio.h +++ b/src/mongo/transport/session_asio.h @@ -57,7 +57,9 @@ class TransportLayerASIO::ASIOSession : public Session { : _socket(std::move(socket)), _tl(tl) {} virtual ~ASIOSession() { - _tl->eraseSession(_sessionsListIterator); + if (_sessionsListIterator) { + _tl->eraseSession(*_sessionsListIterator); + } } TransportLayer* getTransportLayer() const override { @@ -137,8 +139,11 @@ class TransportLayerASIO::ASIOSession : public Session { } _local = endpointToHostAndPort(_socket.local_endpoint()); - _remote = endpointToHostAndPort(_socket.remote_endpoint()); - _sessionsListIterator = std::move(listIt); + _remote = endpointToHostAndPort(_socket.remote_endpoint(ec)); + if (ec) { + LOG(3) << "Unable to get remote endpoint address: " << ec.message(); + } + _sessionsListIterator.emplace(std::move(listIt)); } template @@ -313,7 +318,7 @@ class TransportLayerASIO::ASIOSession : public Session { #endif TransportLayerASIO* const _tl; - TransportLayerASIO::SessionsListIterator _sessionsListIterator; + boost::optional _sessionsListIterator; }; } // namespace transport