diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-10-12 14:09:30 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-10-12 17:44:04 +0000 |
commit | c3b8328cd3ca7e5052b6cb2f746b19137421d268 (patch) | |
tree | d786caac3b38b272d47e7caf5eb8c5290b4695f4 /src/daemon | |
parent | Remove epee header dependency on cryptonote_core (diff) | |
download | monero-c3b8328cd3ca7e5052b6cb2f746b19137421d268.tar.xz |
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
Diffstat (limited to 'src/daemon')
-rw-r--r-- | src/daemon/daemon.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index ea24e32eb..f53649518 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -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 { |