mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 04:21:51 +00:00
dhtnode: avoid deadlock in shutdown
This commit is contained in:
1 parent
d8aa94c8f5
commit
459217b6d6
1 file changed
+9
-5
+9
-5
@@ -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
|
||||
|
||||
Reference in new issue
Block a user