Skip to content
Snippets Groups Projects
Commit 459217b6 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

dhtnode: avoid deadlock in shutdown

parent d8aa94c8
No related branches found
No related tags found
No related merge requests found
...@@ -578,15 +578,19 @@ main(int argc, char **argv) ...@@ -578,15 +578,19 @@ main(int argc, char **argv)
std::mutex m; std::mutex m;
bool done {false}; bool done {false};
node->shutdown([&]() node->shutdown([&]() {
{ {
std::lock_guard<std::mutex> lk(m);
done = true; done = true;
}
cv.notify_all(); cv.notify_all();
}); });
// wait for shutdown // wait for shutdown
{
std::unique_lock<std::mutex> lk(m); std::unique_lock<std::mutex> lk(m);
cv.wait(lk, [&](){ return done; }); cv.wait(lk, [&](){ return done; });
}
node->join(); node->join();
#ifdef WIN32_NATIVE #ifdef WIN32_NATIVE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment