Reduce time to discover the internet gateway

When adding a port forwarding via UPnP, pyrogenesis first needs to
discover the internet gateway to create the forwarding at. To do so, it
utilizes miniupnpc to send an SSDP request and waits 10 seconds until it
processes the responses and continues to add the port forwarding.
As that happens asynchronously it means if players hosting games rely on
UPnP for port forwarding and if their pyrogenesis instance doesn't have
the address of their internet gateway cached, it takes more than 10
seconds after starting to host a game, before players can join. However,
waiting for 10 seconds is completely unnecessary, because the internet
gateway responds immediately to the SSDP request. Therefore, this commit
reduces the time to wait for responses from 10 seconds to 2 seconds,
which is the timeout miniupnpc uses internally as well, when discovering
internet gateways.
This commit is contained in:
Dunedan
2025-02-21 10:08:50 +01:00
parent fcd3fc2aa3
commit 5696f063f5
+3 -3
View File
@@ -248,11 +248,11 @@ void CNetServerWorker::SetupUPnP(const u16 port)
LOGMESSAGE("Net server: using cached IGD = %s", urls.controlURL);
ret = 1;
}
// No cached URL, or it did not respond. Try getting a valid UPnP device for 10 seconds.
// No cached URL, or it did not respond. Try discovering the UPnP IGD for 2 seconds.
#if defined(MINIUPNPC_API_VERSION) && MINIUPNPC_API_VERSION >= 14
else if ((devlist = upnpDiscover(10000, 0, 0, 0, 0, 2, 0)) != NULL)
else if ((devlist = upnpDiscover(2000, 0, 0, 0, 0, 2, 0)) != NULL)
#else
else if ((devlist = upnpDiscover(10000, 0, 0, 0, 0, 0)) != NULL)
else if ((devlist = upnpDiscover(2000, 0, 0, 0, 0, 0)) != NULL)
#endif
{
#if defined(MINIUPNPC_API_VERSION) && MINIUPNPC_API_VERSION >= 18