Skip to content
Snippets Groups Projects
Commit e3240d57 authored by Mohamed Chibani's avatar Mohamed Chibani Committed by Adrien Béraud
Browse files

upnp/natpmp: register controller only if account is enabled

If UPNP is enabled by the user, the UPNP controller must registered
only if the account is enabled.

Gitlab: #639

Change-Id: I993b50ea37fafa847460650d901ac3c3d5039718
parent 042ad25c
No related branches found
No related tags found
No related merge requests found
...@@ -169,13 +169,17 @@ Account::updateUpnpController() ...@@ -169,13 +169,17 @@ Account::updateUpnpController()
{ {
std::lock_guard<std::mutex> lk {upnp_mtx}; std::lock_guard<std::mutex> lk {upnp_mtx};
if (upnpEnabled_ and not upnpCtrl_) { if (not upnpEnabled_ or not isUsable()) {
upnpCtrl_.reset();
return;
}
// UPNP enabled. Create new controller if needed.
if (not upnpCtrl_) {
upnpCtrl_.reset(new upnp::Controller()); upnpCtrl_.reset(new upnp::Controller());
if (not upnpCtrl_) { if (not upnpCtrl_) {
throw std::runtime_error("Failed to create a UPNP Controller instance!"); throw std::runtime_error("Failed to create a UPNP Controller instance!");
} }
} else if (not upnpEnabled_) {
upnpCtrl_.reset();
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment