daemon: fix crash on exit when mining

When exiting while the miner is running, finding a block after
the p2p layer has been shutdown will cause a crash as the now
uninitialized p2p layer is asked to relay the found block to
any peers.
This commit is contained in:
moneromooo-monero 2017-02-12 11:09:21 +00:00
parent cb54eeaa31
commit cf2e75ebb3
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 2 additions and 0 deletions

View File

@ -141,6 +141,7 @@ bool t_daemon::run(bool interactive)
}
mp_internals->rpc.stop();
mp_internals->core.get().get_miner().stop();
MGINFO("Node stopped.");
return true;
}
@ -162,6 +163,7 @@ void t_daemon::stop()
{
throw std::runtime_error{"Can't stop stopped daemon"};
}
mp_internals->core.get().get_miner().stop();
mp_internals->p2p.stop();
mp_internals->rpc.stop();
mp_internals.reset(nullptr); // Ensure resources are cleaned up before we return