Merge pull request #4570

3b04e2e3 daemon: do not run complex code in a signal handler (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2018-10-15 13:49:05 +02:00
commit 92f42b1e81
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
1 changed files with 8 additions and 1 deletions

View File

@ -136,7 +136,14 @@ bool t_daemon::run(bool interactive)
{ {
throw std::runtime_error{"Can't run stopped daemon"}; 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 try
{ {