mirror of
https://github.com/monero-project/monero.git
synced 2024-11-17 16:27:39 +00:00
Merge pull request #4602
6f28667a
daemon: fix reading past stack on exit (moneromooo-monero)
This commit is contained in:
commit
d4e4fac209
1 changed files with 10 additions and 5 deletions
|
@ -137,13 +137,18 @@ bool t_daemon::run(bool interactive)
|
||||||
throw std::runtime_error{"Can't run stopped daemon"};
|
throw std::runtime_error{"Can't run stopped daemon"};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::atomic<bool> stop(false);
|
std::atomic<bool> stop(false), shutdown(false);
|
||||||
boost::thread([&stop, this] {
|
boost::thread stop_thread = boost::thread([&stop, &shutdown, this] {
|
||||||
while (!stop)
|
while (!stop)
|
||||||
epee::misc_utils::sleep_no_w(100);
|
epee::misc_utils::sleep_no_w(100);
|
||||||
|
if (shutdown)
|
||||||
this->stop_p2p();
|
this->stop_p2p();
|
||||||
}).detach();
|
});
|
||||||
tools::signal_handler::install([&stop](int){ stop = true; });
|
epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){
|
||||||
|
stop = true;
|
||||||
|
stop_thread.join();
|
||||||
|
});
|
||||||
|
tools::signal_handler::install([&stop, &shutdown](int){ stop = shutdown = true; });
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue