diff --git a/nano/node/transport/socket.cpp b/nano/node/transport/socket.cpp index 3e57256e91..bc6b25db36 100644 --- a/nano/node/transport/socket.cpp +++ b/nano/node/transport/socket.cpp @@ -37,6 +37,7 @@ nano::transport::socket::socket (nano::node & node_a, endpoint_type_t endpoint_t nano::transport::socket::~socket () { close_internal (); + closed = true; } void nano::transport::socket::start () @@ -280,12 +281,12 @@ void nano::transport::socket::ongoing_checkup () return; } - // If the socket is already dead, close just in case, and stop doing checkups - if (!this_l->alive ()) - { - this_l->close (); - return; - } + boost::asio::post (this_l->strand, [this_l] { + if (!this_l->tcp_socket.is_open ()) + { + this_l->close (); + } + }); nano::seconds_t now = nano::seconds_since_epoch (); auto condition_to_disconnect{ false }; diff --git a/nano/node/transport/socket.hpp b/nano/node/transport/socket.hpp index 6a563e51fa..e3b52d50ce 100644 --- a/nano/node/transport/socket.hpp +++ b/nano/node/transport/socket.hpp @@ -116,7 +116,7 @@ class socket final : public std::enable_shared_from_this