From a0683d18edc54ef8f19af86eab0372438c952ea6 Mon Sep 17 00:00:00 2001 From: Adrien Beraud <adrien.beraud@savoirfairelinux.com> Date: Tue, 22 Aug 2023 18:09:02 -0400 Subject: [PATCH] upnp: cleanup Change-Id: I3fc7888986e2cb17e591167f6b3893cf1c72a0ac --- src/upnp/upnp_context.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/upnp/upnp_context.cpp b/src/upnp/upnp_context.cpp index fb175d1..09f441e 100644 --- a/src/upnp/upnp_context.cpp +++ b/src/upnp/upnp_context.cpp @@ -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; -- GitLab