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

dhtrunner: stop socket after dht

parent 1ce44098
Branches
Tags
No related merge requests found
...@@ -221,7 +221,8 @@ DhtRunner::shutdown(ShutdownCallback cb) { ...@@ -221,7 +221,8 @@ DhtRunner::shutdown(ShutdownCallback cb) {
#endif #endif
std::lock_guard<std::mutex> lck(storage_mtx); std::lock_guard<std::mutex> lck(storage_mtx);
pending_ops_prio.emplace([=](SecureDht& dht) mutable { pending_ops_prio.emplace([=](SecureDht& dht) mutable {
dht.shutdown(cb); if (dht_)
dht_->shutdown(cb);
}); });
cv.notify_all(); cv.notify_all();
} }
...@@ -229,13 +230,16 @@ DhtRunner::shutdown(ShutdownCallback cb) { ...@@ -229,13 +230,16 @@ DhtRunner::shutdown(ShutdownCallback cb) {
void void
DhtRunner::join() DhtRunner::join()
{ {
if (dht_)
if (auto sock = dht_->getSocket())
sock->stop();
running = false; running = false;
cv.notify_all(); cv.notify_all();
bootstrap_cv.notify_all(); bootstrap_cv.notify_all();
if (peerDiscovery_) peerDiscovery_->stop(); if (peerDiscovery_) peerDiscovery_->stop();
{
std::lock_guard<std::mutex> lck(dht_mtx);
if (dht_)
if (auto sock = dht_->getSocket())
sock->stop();
}
if (dht_thread.joinable()) if (dht_thread.joinable())
dht_thread.join(); dht_thread.join();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment