From 0e1dd92d9b5946fc08db77c93658c94ccf536b80 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Mon, 17 Nov 2014 16:04:33 -0800 Subject: [PATCH] Fix case where slot==nullptr in Overlay: This changes the Overlay to correctly handle the case when nullptr is returned by PeerFinder new_inbound_slot on a detected self-connection. --- src/ripple/overlay/impl/OverlayImpl.cpp | 27 ++++++++++--------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/ripple/overlay/impl/OverlayImpl.cpp b/src/ripple/overlay/impl/OverlayImpl.cpp index 59bd156d44..a399ba2b5d 100644 --- a/src/ripple/overlay/impl/OverlayImpl.cpp +++ b/src/ripple/overlay/impl/OverlayImpl.cpp @@ -161,10 +161,11 @@ OverlayImpl::onLegacyPeerHello ( beast::IPAddressConversion::from_asio(local_endpoint), beast::IPAddressConversion::from_asio(remote_address)); - addpeer (std::make_shared(std::move(ssl_bundle), - boost::asio::const_buffers_1(buffer), - beast::IPAddressConversion::from_asio(remote_address), - *this, m_resourceManager, *m_peerFinder, slot)); + if (slot != nullptr) + return addpeer (std::make_shared(std::move(ssl_bundle), + boost::asio::const_buffers_1(buffer), + beast::IPAddressConversion::from_asio(remote_address), + *this, m_resourceManager, *m_peerFinder, slot)); } Handoff @@ -192,23 +193,17 @@ OverlayImpl::onHandoff (std::unique_ptr && ssl_bundle, beast::IPAddressConversion::from_asio(local_endpoint), beast::IPAddressConversion::from_asio(remote_address)); -#if 0 if (slot == nullptr) -#else - // For now, always redirect. - if (true) -#endif { - // Full, give them some addresses - handoff.response = makeRedirectResponse(slot, request); - handoff.keep_alive = request.keep_alive(); + // self connect + handoff.moved = false; return handoff; } - addpeer (std::make_shared(std::move(ssl_bundle), - std::move(request), beast::IPAddressConversion::from_asio(remote_address), - *this, m_resourceManager, *m_peerFinder, slot)); - handoff.moved = true; + // For now, always redirect + // Full, give them some addresses + handoff.response = makeRedirectResponse(slot, request); + handoff.keep_alive = request.keep_alive(); return handoff; }