Fixes to Overlay:

* Make ~Peer virtual
* Call close in ConnectAttempt::stop
* Handle nullptr return in new_outbound_slot
* Check gracefulClose_ in read loop
This commit is contained in:
Vinnie Falco
2015-01-20 14:34:52 -08:00
parent a470dda4e6
commit 40e138627b
5 changed files with 23 additions and 14 deletions

View File

@@ -28,8 +28,8 @@ namespace ripple {
ConnectAttempt::ConnectAttempt (boost::asio::io_service& io_service,
endpoint_type const& remote_endpoint, Resource::Consumer usage,
beast::asio::ssl_bundle::shared_context const& context,
std::uint32_t id, beast::Journal journal,
OverlayImpl& overlay)
std::uint32_t id, PeerFinder::Slot::ptr const& slot,
beast::Journal journal, OverlayImpl& overlay)
: Child (overlay)
, id_ (id)
, sink_ (journal, OverlayImpl::makePrefix(id))
@@ -49,8 +49,7 @@ ConnectAttempt::ConnectAttempt (boost::asio::io_service& io_service,
boost::asio::buffer(data, size)));
}
, response_, false)
, slot_(overlay_.peerFinder().new_outbound_slot(
beast::IPAddressConversion::from_asio(remote_endpoint)))
, slot_ (slot)
{
if (journal_.trace) journal_.trace <<
"Connect " << remote_endpoint;
@@ -75,6 +74,7 @@ ConnectAttempt::stop()
if (journal_.debug) journal_.debug <<
"Stop";
}
close();
}
void
@@ -191,14 +191,13 @@ void
ConnectAttempt::onHandshake (error_code ec)
{
cancelTimer();
if(! stream_.next_layer().is_open())
return;
if(ec == boost::asio::error::operation_aborted)
return;
endpoint_type local_endpoint =
stream_.next_layer().local_endpoint(ec);
endpoint_type local_endpoint;
if (! ec)
local_endpoint = stream_.next_layer().local_endpoint(ec);
if(ec)
return fail("onHandshake", ec);
if(journal_.trace) journal_.trace <<