mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-30 06:43:28 +01:00
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
This commit is contained in:
parent
e736964a0c
commit
c3b8328cd3
@ -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
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user