Skip to content

Commit

Permalink
Fix stopping of bootstrap workers
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Jul 2, 2024
1 parent 0b2dcf1 commit 9cc4b95
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand All @@ -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 ();
Expand Down
10 changes: 10 additions & 0 deletions nano/node/transport/tcp_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ bool nano::transport::tcp_listener::connect (asio::ip::address ip, uint16_t port
{
nano::unique_lock<nano::mutex> lock{ mutex };

if (stopped)
{
return false; // Rejected
}

if (port == 0)
{
port = node.network_params.network.default_node_port;
Expand Down Expand Up @@ -371,6 +376,11 @@ auto nano::transport::tcp_listener::accept_one (asio::ip::tcp::socket raw_socket

nano::unique_lock<nano::mutex> 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));
Expand Down

0 comments on commit 9cc4b95

Please sign in to comment.