From b0896aa755d8fcbb6c0cef25b31bed8157829c8f Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Wed, 17 Jan 2024 20:10:06 +0000 Subject: [PATCH] Store pointer to boost::asio::signal_set and cancel when ipc_server::stop is called. Previously the signals weren't cancelled on ipc_server and would remain running until the io_context was destroyed. --- nano/node/ipc/ipc_server.cpp | 7 +++++-- nano/node/ipc/ipc_server.hpp | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nano/node/ipc/ipc_server.cpp b/nano/node/ipc/ipc_server.cpp index 9eaf1e7509..777a9ee2bb 100644 --- a/nano/node/ipc/ipc_server.cpp +++ b/nano/node/ipc/ipc_server.cpp @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -614,7 +613,7 @@ nano::ipc::ipc_server::ipc_server (nano::node & node_a, nano::node_rpc_config co } #ifndef _WIN32 // Hook up config reloading through the HUP signal - auto signals (std::make_shared (node.io_ctx, SIGHUP)); + signals = std::make_shared (node.io_ctx, SIGHUP); await_hup_signal (signals, *this); #endif if (node_a.config.ipc_config.transport_domain.enabled) @@ -659,6 +658,10 @@ void nano::ipc::ipc_server::stop () { transport->stop (); } + if (signals) + { + signals->cancel (); + } } std::optional nano::ipc::ipc_server::listening_tcp_port () const diff --git a/nano/node/ipc/ipc_server.hpp b/nano/node/ipc/ipc_server.hpp index a9f175dbbc..378d78eb32 100644 --- a/nano/node/ipc/ipc_server.hpp +++ b/nano/node/ipc/ipc_server.hpp @@ -6,6 +6,8 @@ #include #include +#include + #include #include @@ -41,6 +43,7 @@ namespace ipc nano::ipc::access access; std::unique_ptr file_remover; std::vector> transports; + std::shared_ptr signals; }; } }