Skip to content
Snippets Groups Projects
Commit a06fd592 authored by Guillaume Roguez's avatar Guillaume Roguez Committed by gerrit2
Browse files

upnp: fix waiting while holding a lock


Blocking function (sleep) called when inside locked region.
This patch uses a move-in-temporary idiom to prevent that.
Was detected by Coverity scan.

Change-Id: I7ab74001c3d9de11e1d95b5e4a1c1bd0a8dce8c9
Reviewed-by: default avatarOlivier SOLDANO <olivier.soldano@savoirfairelinux.com>
parent 581b1a16
No related branches found
No related tags found
No related merge requests found
......@@ -138,9 +138,13 @@ UPnPContext::UPnPContext()
pmp_igd->clearAll_ = false;
pmp_igd->toRemove_.clear();
} else if (not pmp_igd->toRemove_.empty()) {
for (auto& m : pmp_igd->toRemove_)
PMPaddPortMapping(*pmp_igd, natpmp, m, true);
decltype(pmp_igd->toRemove_) removed = std::move(pmp_igd->toRemove_);
pmp_igd->toRemove_.clear();
lk.unlock();
for (auto& m : removed) {
PMPaddPortMapping(*pmp_igd, natpmp, m, true);
}
lk.lock();
}
auto mapping = pmp_igd->getNextMappingToRenew();
if (mapping and mapping->renewal_ < now)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment