daemon: do not run complex code in a signal handler

instead, delegate the work to a one off thread
and notify it from the signal handler
release-v0.5.1
moneromooo-monero 6 years ago
parent 77ef8c1839
commit 3b04e2e3d4
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3

@ -136,7 +136,14 @@ bool t_daemon::run(bool interactive)
{
throw std::runtime_error{"Can't run stopped daemon"};
}
tools::signal_handler::install(std::bind(&daemonize::t_daemon::stop_p2p, this));
std::atomic<bool> stop(false);
boost::thread([&stop, this] {
while (!stop)
epee::misc_utils::sleep_no_w(100);
this->stop_p2p();
}).detach();
tools::signal_handler::install([&stop](int){ stop = true; });
try
{

Loading…
Cancel
Save