Skip to content

Commit

Permalink
Merge pull request #4367 from clemahieu/ipc_server_signals
Browse files Browse the repository at this point in the history
Store pointer to boost::asio::signal_set and cancel when ipc_server::stop is called.
  • Loading branch information
clemahieu authored Feb 6, 2024
2 parents 647c3c4 + b0896aa commit ef25ca6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions nano/node/ipc/ipc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <nano/node/json_handler.hpp>
#include <nano/node/node.hpp>

#include <boost/asio/signal_set.hpp>
#include <boost/endian/conversion.hpp>
#include <boost/property_tree/json_parser.hpp>

Expand Down Expand Up @@ -602,7 +601,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<boost::asio::signal_set> (node.io_ctx, SIGHUP));
signals = std::make_shared<boost::asio::signal_set> (node.io_ctx, SIGHUP);
await_hup_signal (signals, *this);
#endif
if (node_a.config.ipc_config.transport_domain.enabled)
Expand Down Expand Up @@ -647,6 +646,10 @@ void nano::ipc::ipc_server::stop ()
{
transport->stop ();
}
if (signals)
{
signals->cancel ();
}
}

std::optional<std::uint16_t> nano::ipc::ipc_server::listening_tcp_port () const
Expand Down
3 changes: 3 additions & 0 deletions nano/node/ipc/ipc_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <nano/node/ipc/ipc_broker.hpp>
#include <nano/node/node_rpc_config.hpp>

#include <boost/asio/signal_set.hpp>

#include <atomic>
#include <memory>

Expand Down Expand Up @@ -41,6 +43,7 @@ namespace ipc
nano::ipc::access access;
std::unique_ptr<dsock_file_remover> file_remover;
std::vector<std::shared_ptr<nano::ipc::transport>> transports;
std::shared_ptr<boost::asio::signal_set> signals;
};
}
}

0 comments on commit ef25ca6

Please sign in to comment.