Skip to content

Commit

Permalink
SERVER-29769 Only erase session if session is valid after accept
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreams committed Jun 26, 2017
1 parent e245cac commit f052e0b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/mongo/transport/session_asio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 <typename MutableBufferSequence, typename CompleteHandler>
Expand Down Expand Up @@ -313,7 +318,7 @@ class TransportLayerASIO::ASIOSession : public Session {
#endif

TransportLayerASIO* const _tl;
TransportLayerASIO::SessionsListIterator _sessionsListIterator;
boost::optional<TransportLayerASIO::SessionsListIterator> _sessionsListIterator;
};

} // namespace transport
Expand Down

0 comments on commit f052e0b

Please sign in to comment.