net_udp.c (UDP_Init): lose the goto in OSX workaround, restrict the workaround to OSX builds only.

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1577 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Ozkan Sezer 2018-04-20 14:35:32 +00:00
parent 8b24098367
commit 39459b19cb
1 changed files with 9 additions and 11 deletions

View File

@ -40,7 +40,7 @@ static in_addr_t myAddr;
sys_socket_t UDP_Init (void)
{
int err;
char *colon;
char *tst;
char buff[MAXHOSTNAMELEN];
struct hostent *local;
struct qsockaddr addr;
@ -59,18 +59,18 @@ sys_socket_t UDP_Init (void)
else
{
buff[MAXHOSTNAMELEN - 1] = 0;
#ifdef PLATFORM_OSX
// 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))
tst = strstr(buff, ".local");
if (tst && tst[6] == '\0')
{
Con_SafePrintf("UDP_Init: skipping gethostbyname for %s\n", buff);
goto skip_gethostbyname;
}
local = gethostbyname(buff);
if (local == NULL)
else
#endif
if (!(local = gethostbyname(buff)))
{
Con_SafePrintf("UDP_Init: gethostbyname failed (%s)\n",
hstrerror(h_errno));
@ -85,7 +85,6 @@ 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");
@ -98,9 +97,8 @@ skip_gethostbyname:
UDP_GetSocketAddr (net_controlsocket, &addr);
strcpy(my_tcpip_address, UDP_AddrToString (&addr));
colon = strrchr (my_tcpip_address, ':');
if (colon)
*colon = 0;
tst = strrchr(my_tcpip_address, ':');
if (tst) *tst = 0;
Con_SafePrintf("UDP Initialized\n");
tcpipAvailable = true;