dhtnode: avoid deadlock in shutdown

This commit is contained in:
Adrien Béraud committed 2019-07-17 14:53:41 -04:00
1 parent d8aa94c8f5
commit 459217b6d6
1 file changed
+9 -5
+9 -5
View File
@@ -578,15 +578,19 @@ main(int argc, char **argv)
std::mutex m;
bool done {false};
node->shutdown([&]()
{
done = true;
node->shutdown([&]() {
{
std::lock_guard<std::mutex> lk(m);
done = true;
}
cv.notify_all();
});
// wait for shutdown
std::unique_lock<std::mutex> lk(m);
cv.wait(lk, [&](){ return done; });
{
std::unique_lock<std::mutex> lk(m);
cv.wait(lk, [&](){ return done; });
}
node->join();
#ifdef WIN32_NATIVE