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

ConnectionManager: avoid duplicate IDs

Change-Id: Ie56f065a58b9a5453d3b2df86cd7a7b249fac077
parent 651a4c6f
No related branches found
No related tags found
No related merge requests found
......@@ -747,15 +747,16 @@ ConnectionManager::Impl::connectDevice(const std::shared_ptr<dht::crypto::Certif
cb(nullptr, deviceId);
return;
}
dht::Value::Id vid = ValueIdDist(1, ID_MAX_VAL)(sthis->rand);
dht::Value::Id vid;
auto isConnectingToDevice = false;
{
std::lock_guard<std::mutex> lk(sthis->connectCbsMtx_);
vid = ValueIdDist(1, ID_MAX_VAL)(sthis->rand);
auto pendingsIt = sthis->pendingOperations_.find(deviceId);
if (pendingsIt != sthis->pendingOperations_.end()) {
const auto& pendings = pendingsIt->second;
while (pendings.connecting.find(vid) != pendings.connecting.end()
&& pendings.waiting.find(vid) != pendings.waiting.end()) {
|| pendings.waiting.find(vid) != pendings.waiting.end()) {
vid = ValueIdDist(1, ID_MAX_VAL)(sthis->rand);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment