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

upnp: cleanup

Change-Id: I3fc7888986e2cb17e591167f6b3893cf1c72a0ac
parent a61adb53
No related branches found
No related tags found
No related merge requests found
......@@ -737,12 +737,12 @@ UPnPContext::pruneMappingList()
auto remoteMapList = protocol->getMappingsListByDescr(igd,
Mapping::UPNP_MAPPING_DESCRIPTION_PREFIX);
if (remoteMapList.empty()) {
/*if (remoteMapList.empty()) {
std::lock_guard<std::mutex> lock(mappingMutex_);
if (not getMappingList(PortType::TCP).empty() or getMappingList(PortType::TCP).empty()) {
// JAMI_WARN("We have provisionned mappings but the PUPNP IGD returned an empty list!");
}
}
}*/
pruneUnMatchedMappings(igd, remoteMapList);
pruneUnTrackedMappings(igd, remoteMapList);
......@@ -755,15 +755,12 @@ UPnPContext::pruneUnMatchedMappings(const std::shared_ptr<IGD>& igd,
// Check/synchronize local mapping list with the list
// returned by the IGD.
PortType types[2] {PortType::TCP, PortType::UDP};
for (auto& type : types) {
for (auto type: {PortType::TCP, PortType::UDP}) {
// Use a temporary list to avoid processing mappings while holding the lock.
std::list<Mapping::sharedPtr_t> toRemoveList;
{
std::lock_guard<std::mutex> lock(mappingMutex_);
auto& mappingList = getMappingList(type);
for (auto const& [_, map] : mappingList) {
for (auto const& [_, map] : getMappingList(type)) {
// Only check mappings allocated by UPNP protocol.
if (map->getProtocol() != NatProtocolType::PUPNP) {
continue;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment