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

dhtnode: gracefully stop node

parent 67464fde
Branches
Tags
No related merge requests found
......@@ -265,6 +265,21 @@ main(int argc, char **argv)
std::cout << std::endl << e.what() << std::endl;
}
std::condition_variable cv;
std::mutex m;
std::atomic_bool done {false};
dht.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.load(); });
dht.join();
gnutls_global_deinit();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment