UDP_Init: don't bother calling gethostbyname() if our hostname ends in ".local"

(a macOS thing), because it blocks for a few seconds and then fails
(on my system anyway), so it's pointless.

Fixes an annoying startup pause on macOS, which was reported as
https://sourceforge.net/p/quakespasm/bugs/15/

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1403 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Eric Wasylishen 2017-04-26 01:38:38 +00:00
parent f92ce77fc9
commit 4bea6d51e2

View file

@ -59,6 +59,16 @@ sys_socket_t UDP_Init (void)
else
{
buff[MAXHOSTNAMELEN - 1] = 0;
// ericw -- if our hostname ends in ".local" (a macOS thing),
// don't bother calling gethostbyname(), because it blocks for a few seconds
// and then fails (on my system anyway.)
if (strstr(buff, ".local") == (buff + strlen(buff) - 6))
{
Con_SafePrintf("UDP_Init: skipping gethostbyname for %s\n", buff);
goto skip_gethostbyname;
}
local = gethostbyname(buff);
if (local == NULL)
{
@ -75,6 +85,7 @@ sys_socket_t UDP_Init (void)
}
}
skip_gethostbyname:
if ((net_controlsocket = UDP_OpenSocket(0)) == INVALID_SOCKET)
{
Con_SafePrintf("UDP_Init: Unable to open control socket, UDP disabled\n");