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

connectionmanager: destroy ICE transport after unlock

Change-Id: I39a23e0e983716bb5fd6ac615aca57cd7d2575c1
parent e7ed15d5
Branches
No related tags found
Loading
......@@ -980,7 +980,10 @@ ConnectionManager::Impl::startConnection(const std::shared_ptr<DeviceInfo>& di,
auto eraseInfo = [w = weak_from_this(), diw=std::weak_ptr(di), vid] {
if (auto di = diw.lock()) {
std::unique_lock lk(di->mutex_);
if (di->info.erase(vid)) {
auto it = di->info.find(vid);
if (it != di->info.end()) {
// destroy at the end of the scope to avoid blocking the mutex
auto ci_node = di->info.extract(it);
auto ops = di->extractPendingOperations(vid, nullptr);
if (di->empty()) {
if (auto shared = w.lock())
......@@ -1458,7 +1461,10 @@ ConnectionManager::Impl::onDhtPeerRequest(const PeerConnectionRequest& req,
auto shared = w.lock();
if (auto di = wdi.lock()) {
std::unique_lock lk(di->mutex_);
di->info.erase(id);
auto it = di->info.find(id);
if (it != di->info.end()) {
// destroy at the end of the scope to avoid blocking the mutex
auto ci_node = di->info.extract(it);
auto ops = di->extractPendingOperations(id, nullptr);
if (di->empty()) {
if (shared)
......@@ -1470,6 +1476,7 @@ ConnectionManager::Impl::onDhtPeerRequest(const PeerConnectionRequest& req,
if (shared && shared->connReadyCb_)
shared->connReadyCb_(di->deviceId, "", nullptr);
}
}
};
ice_config.master = true;
......@@ -1700,8 +1707,8 @@ ConnectionManager::Impl::storeActiveIpAddress(std::function<void()>&& cb)
if (hasIpv4 and hasIpv6)
break;
}
dht::ThreadPool::io().run([cb = std::move(cb)] {
if (cb)
dht::ThreadPool::io().run([cb = std::move(cb)] {
cb();
});
});
......@@ -2062,7 +2069,9 @@ ConnectionManager::getConnectionList(const DeviceId& device) const
connectionsList = deviceInfo->getConnectionList(pimpl_->certStore());
}
} else {
for (const auto& deviceInfo : pimpl_->infos_.getDeviceInfos()) {
auto deviceInfos = pimpl_->infos_.getDeviceInfos();
connectionsList.reserve(deviceInfos.size());
for (const auto& deviceInfo : deviceInfos) {
auto cl = deviceInfo->getConnectionList(pimpl_->certStore());
connectionsList.insert(connectionsList.end(), std::make_move_iterator(cl.begin()), std::make_move_iterator(cl.end()));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment