From f9b361be8a32fec2cc6ef0f835e4b8077b713753 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 14 Jun 2015 00:30:04 +0100 Subject: daemon: fix an exit crash --- src/daemon/daemon.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/daemon/daemon.cpp') diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 2bd592611..6a5943c8b 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -126,7 +126,7 @@ bool t_daemon::run(bool interactive) if (interactive) { rpc_commands = new daemonize::t_command_server(0, 0, false, mp_internals->rpc.get_server()); - rpc_commands->start_handling(std::bind(&daemonize::t_daemon::stop, this)); + rpc_commands->start_handling(std::bind(&daemonize::t_daemon::stop_p2p, this)); } mp_internals->p2p.run(); // blocks until p2p goes down @@ -163,4 +163,13 @@ void t_daemon::stop() mp_internals.reset(nullptr); // Ensure resources are cleaned up before we return } +void t_daemon::stop_p2p() +{ + if (nullptr == mp_internals) + { + throw std::runtime_error{"Can't send stop signal to a stopped daemon"}; + } + mp_internals->p2p.get().send_stop_signal(); +} + } // namespace daemonize -- cgit v1.2.3