Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle remote endpoint fetching more carefully #1051

Merged
merged 1 commit into from
Aug 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions rai/node/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ void rai::socket::start (std::chrono::steady_clock::time_point timeout_a)
{
if (this_l->ticket == ticket_l)
{
this_l->socket_m.close ();
if (this_l->node->config.logging.bulk_pull_logging ())
{
BOOST_LOG (this_l->node->log) << boost::str (boost::format ("Disconnecting from %1% due to timeout") % this_l->socket_m.remote_endpoint ());
BOOST_LOG (this_l->node->log) << boost::str (boost::format ("Disconnecting from %1% due to timeout") % this_l->remote_endpoint ());
}

this_l->close ();
}
}
});
Expand All @@ -78,12 +79,24 @@ void rai::socket::stop ()

void rai::socket::close ()
{
socket_m.close ();
if (socket_m.is_open ())
{
socket_m.close ();
}
}

rai::tcp_endpoint rai::socket::remote_endpoint ()
{
return socket_m.remote_endpoint ();
rai::tcp_endpoint endpoint;

if (socket_m.is_open ())
{
boost::system::error_code remote_endpoint_error;

endpoint = socket_m.remote_endpoint (remote_endpoint_error);
}

return endpoint;
}

rai::bootstrap_client::bootstrap_client (std::shared_ptr<rai::node> node_a, std::shared_ptr<rai::bootstrap_attempt> attempt_a, rai::tcp_endpoint const & endpoint_a) :
Expand Down