Skip to content
Snippets Groups Projects
Commit 2361f77f authored by Sébastien Blin's avatar Sébastien Blin Committed by Adrien Béraud
Browse files

swarm_manager: move toConnectCb_ in ioPool

Else, it can cause a deadlock with connManagerMtx_

Change-Id: Idd9bb994a6c3f088b2998140a17fd41786d961a3
parent 3ed0c63b
No related branches found
No related tags found
No related merge requests found
...@@ -55,15 +55,22 @@ SwarmManager::setKnownNodes(const std::vector<NodeId>& known_nodes) ...@@ -55,15 +55,22 @@ SwarmManager::setKnownNodes(const std::vector<NodeId>& known_nodes)
} }
} }
} }
dht::ThreadPool::io().run([w=weak(), newNodes=std::move(newNodes)] {
auto shared = w.lock();
if (!shared)
return;
// If we detect a new node which already got a TCP link // If we detect a new node which already got a TCP link
// we can use it to speed-up the bootstrap (because opening // we can use it to speed-up the bootstrap (because opening
// a new channel will be easy) // a new channel will be easy)
std::set<NodeId> toConnect; std::set<NodeId> toConnect;
for (const auto& nodeId: newNodes) { for (const auto& nodeId: newNodes) {
if (toConnectCb_ && toConnectCb_(nodeId)) if (shared->toConnectCb_ && shared->toConnectCb_(nodeId))
toConnect.emplace(nodeId); toConnect.emplace(nodeId);
} }
maintainBuckets(toConnect); shared->maintainBuckets(toConnect);
});
} }
void void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment