mirror of
https://github.com/monero-project/monero.git
synced 2024-11-18 10:01:02 +00:00
daemon: fix an exit crash
This commit is contained in:
parent
d6ba5ef8c5
commit
f9b361be8a
2 changed files with 12 additions and 1 deletions
|
@ -126,7 +126,7 @@ bool t_daemon::run(bool interactive)
|
||||||
if (interactive)
|
if (interactive)
|
||||||
{
|
{
|
||||||
rpc_commands = new daemonize::t_command_server(0, 0, false, mp_internals->rpc.get_server());
|
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
|
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
|
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
|
} // namespace daemonize
|
||||||
|
|
|
@ -38,6 +38,8 @@ class t_internals;
|
||||||
class t_daemon final {
|
class t_daemon final {
|
||||||
public:
|
public:
|
||||||
static void init_options(boost::program_options::options_description & option_spec);
|
static void init_options(boost::program_options::options_description & option_spec);
|
||||||
|
private:
|
||||||
|
void stop_p2p();
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<t_internals> mp_internals;
|
std::unique_ptr<t_internals> mp_internals;
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue