Timeout during UPnPContext shutdown
The function PUPnP::terminate(std::condition_variable&)
, which is called when UPnP shuts down, includes the following line:
cvOngoing_.wait(lk, [&]() { return ongoingOps_ == 0; });
This line frequently (though not always) takes a very long time to complete due to a timeout in PUPnP::downLoadIgdDescription
. More specifically, PUPnP::downLoadIgdDescription
calls UpnpDownloadXmlDoc
, which calls UpnpDownloadUrlItem
, which calls http_Download
, which calls http_RequestAndResponse
. The http_RequestAndResponse
function returns a UPNP_E_SOCKET_CONNECT
error code after its attempt to establish a connection (via a call to private_connect
) fails. This can cause a delay of over two minutes when closing Jami if multiple downloads fail (which does happen - I often got four failure while testing, e.g.:
PUPnP: Discovered a new IGD [uuid:C084EDD9-1DE4-9E6A-DEAD-34A8C7031F76 url: http://192.168.51.82:1780/InternetGatewayDevice.xml]
PUPnP: Discovered a new IGD [uuid:0F2A137C-6FF1-C2BE-A962-0150A7DA9FA9 url: http://192.168.51.82:1780/InternetGatewayDevice.xml]
PUPnP: Discovered a new IGD [uuid:64D4257E-8CFC-3924-97C1-9183CCBFEDB1 url: http://192.168.51.82:1780/InternetGatewayDevice.xml]
PUPnP: Discovered a new IGD [uuid:08780A31-017A-6198-F7A9-0B060FA1B336 url: http://192.168.51.82:1780/InternetGatewayDevice.xml]
[...]
Error downloading device XML document from http://192.168.51.82:1780/InternetGatewayDevice.xml -> UPNP_E_SOCKET_CONNECT
Error downloading device XML document from http://192.168.51.82:1780/InternetGatewayDevice.xml -> UPNP_E_SOCKET_CONNECT
Error downloading device XML document from http://192.168.51.82:1780/InternetGatewayDevice.xml -> UPNP_E_SOCKET_CONNECT
Error downloading device XML document from http://192.168.51.82:1780/InternetGatewayDevice.xml -> UPNP_E_SOCKET_CONNECT
)