Skip to content

Commit

Permalink
DOUBLE STRAND WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Mar 17, 2024
1 parent cb775e6 commit 5d16d18
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions nano/node/transport/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,16 @@ std::chrono::seconds nano::transport::socket::get_default_timeout_value () const

void nano::transport::socket::set_silent_connection_tolerance_time (std::chrono::seconds tolerance_time_a)
{
boost::asio::dispatch (strand, boost::asio::bind_executor (strand, [this_l = shared_from_this (), tolerance_time_a] () {
boost::asio::dispatch (strand, [this_l = shared_from_this (), tolerance_time_a] () {
this_l->silent_connection_tolerance_time = tolerance_time_a;
}));
});
}

void nano::transport::socket::close ()
{
boost::asio::dispatch (strand, boost::asio::bind_executor (strand, [this_l = shared_from_this ()] {
boost::asio::dispatch (strand, [this_l = shared_from_this ()] {
this_l->close_internal ();
}));
});
}

// This must be called from a strand or the destructor
Expand All @@ -329,9 +329,10 @@ void nano::transport::socket::close_internal ()
send_queue.clear ();

default_timeout = std::chrono::seconds (0);
boost::system::error_code ec;

debug_assert (strand.running_in_this_thread ());
// Ignore error code for shutdown as it is best-effort
boost::system::error_code ec;
tcp_socket.shutdown (boost::asio::ip::tcp::socket::shutdown_both, ec);
tcp_socket.close (ec);

Expand Down

0 comments on commit 5d16d18

Please sign in to comment.