From 9cc4b953fe6c1d2a49b9564dc03d91ccfef521df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Tue, 2 Jul 2024 19:08:52 +0200 Subject: [PATCH] Fix stopping of bootstrap workers --- nano/node/node.cpp | 2 +- nano/node/transport/tcp_listener.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/nano/node/node.cpp b/nano/node/node.cpp index a2521e49cf..217f50de9f 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -733,6 +733,7 @@ void nano::node::stop () logger.info (nano::log::type::node, "Node stopping..."); + tcp_listener.stop (); bootstrap_workers.stop (); wallet_workers.stop (); election_workers.stop (); @@ -759,7 +760,6 @@ void nano::node::stop () websocket.stop (); bootstrap_server.stop (); bootstrap_initiator.stop (); - tcp_listener.stop (); port_mapping.stop (); wallets.stop (); stats.stop (); diff --git a/nano/node/transport/tcp_listener.cpp b/nano/node/transport/tcp_listener.cpp index a63499727a..0e3838626a 100644 --- a/nano/node/transport/tcp_listener.cpp +++ b/nano/node/transport/tcp_listener.cpp @@ -222,6 +222,11 @@ bool nano::transport::tcp_listener::connect (asio::ip::address ip, uint16_t port { nano::unique_lock lock{ mutex }; + if (stopped) + { + return false; // Rejected + } + if (port == 0) { port = node.network_params.network.default_node_port; @@ -371,6 +376,11 @@ auto nano::transport::tcp_listener::accept_one (asio::ip::tcp::socket raw_socket nano::unique_lock lock{ mutex }; + if (stopped) + { + return { accept_result::rejected }; + } + if (auto result = check_limits (remote_endpoint.address (), type); result != accept_result::accepted) { stats.inc (nano::stat::type::tcp_listener, nano::stat::detail::accept_rejected, to_stat_dir (type));