diff options
author | Riccardo Spagni <ric@spagni.net> | 2015-06-14 13:09:47 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2015-06-14 13:09:53 +0200 |
commit | 1595187ae2d97e0720ab2ac309f9b4784137d79f (patch) | |
tree | b723732ed3c3d44b818360a8f177a8c728969039 | |
parent | Merge pull request #318 (diff) | |
parent | daemon: fix an exit crash (diff) | |
download | monero-1595187ae2d97e0720ab2ac309f9b4784137d79f.tar.xz |
Merge pull request #320
f9b361b daemon: fix an exit crash (moneromooo-monero)
-rw-r--r-- | src/daemon/daemon.cpp | 11 | ||||
-rw-r--r-- | src/daemon/daemon.h | 2 |
2 files changed, 12 insertions, 1 deletions
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 diff --git a/src/daemon/daemon.h b/src/daemon/daemon.h index 1a6a53d3b..8ed2a2f03 100644 --- a/src/daemon/daemon.h +++ b/src/daemon/daemon.h @@ -39,6 +39,8 @@ class t_daemon final { public: static void init_options(boost::program_options::options_description & option_spec); private: + void stop_p2p(); +private: std::unique_ptr<t_internals> mp_internals; public: t_daemon( |