Skip to content
Snippets Groups Projects
Commit 7a33c7c3 authored by Amna Snene's avatar Amna Snene
Browse files

pupnp: Log a warning if UPnP is already initialized

Currently, any flag other than UPNP_E_SUCCESS terminates UPnP during initialization. However, the UPNP_E_INIT flag (indicating UPnP is already initialized) should not cause termination. NAT-PMP has no equivalent flag.

Change-Id: Ia40508a4c07a141dbd5e2effe5f11dff05607d7c
parent 5170f76d
Branches
No related tags found
No related merge requests found
......@@ -114,10 +114,16 @@ PUPnP::initUpnpLib()
auto hostinfo = ip_utils::getHostName();
int upnp_err = UpnpInit2(hostinfo.interface.empty() ? nullptr : hostinfo.interface.c_str(), 0);
if (upnp_err != UPNP_E_SUCCESS) {
if (logger_) logger_->error("PUPnP: Can't initialize libupnp: {}", UpnpGetErrorMessage(upnp_err));
UpnpFinish();
initialized_ = false;
return;
if (upnp_err == UPNP_E_INIT) {
if (logger_) logger_->warn("PUPnP: libupnp already initialized");
initialized_ = true;
return;
}else {
if (logger_) logger_->error("PUPnP: Can't initialize libupnp: {}", UpnpGetErrorMessage(upnp_err));
UpnpFinish();
initialized_ = false;
return;
}
}
// Disable embedded WebServer if any.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment