Skip to content
Snippets Groups Projects
Commit 546698a9 authored by Mohamed Chibani's avatar Mohamed Chibani Committed by Sébastien Blin
Browse files

upnp: use asynchronous version of PUPNP DeletePortMapping method

Calls to DeletePortMapping method are made synchronous which may cause
lags. This might be particulary critical if the IGD does not respond
fast enough since the calls are made on the shared main thread.

Change-Id: I57366a70ffeb294e6277c4e8d946b339a8277309
Gitlab: #420
parent 973afbcf
No related branches found
No related tags found
No related merge requests found
......@@ -1395,15 +1395,16 @@ PUPnP::actionDeletePortMapping(const UPnPIGD& igd,
protocol.c_str());
action.reset(action_container_ptr);
int upnp_err = UpnpSendAction(ctrlptHandle_,
int upnp_err = UpnpSendActionAsync(ctrlptHandle_,
igd.getControlURL().c_str(),
igd.getServiceType().c_str(),
nullptr,
action.get(),
&response_container_ptr);
ctrlPtCallback,
this);
if (upnp_err != UPNP_E_SUCCESS) {
JAMI_WARN("PUPnP: Failed to send %s from: %s, %d: %s",
JAMI_WARN("PUPnP: Failed to send %s request from: %s, %d: %s",
action_name.c_str(),
igd.getServiceType().c_str(),
upnp_err,
......@@ -1411,24 +1412,9 @@ PUPnP::actionDeletePortMapping(const UPnPIGD& igd,
return false;
}
if (not response_container_ptr) {
JAMI_WARN("PUPnP: Failed to get response from %s", action_name.c_str());
return false;
}
response.reset(response_container_ptr);
// Check if there is an error code.
std::string errorCode = getFirstDocItem(response.get(), "errorCode");
if (not errorCode.empty()) {
std::string errorDescription = getFirstDocItem(response.get(), "errorDescription");
JAMI_WARN("PUPnP: %s returned with error: %s: %s",
JAMI_DBG("PUPnP: Successfully sent %s request from %s",
action_name.c_str(),
errorCode.c_str(),
errorDescription.c_str());
return false;
}
JAMI_WARN("PUPnP: Closed port %s %s", port_external.c_str(), protocol.c_str());
igd.getServiceType().c_str());
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment