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:
parent
8b24098367
commit
39459b19cb
|
@ -40,7 +40,7 @@ static in_addr_t myAddr;
|
||||||
sys_socket_t UDP_Init (void)
|
sys_socket_t UDP_Init (void)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
char *colon;
|
char *tst;
|
||||||
char buff[MAXHOSTNAMELEN];
|
char buff[MAXHOSTNAMELEN];
|
||||||
struct hostent *local;
|
struct hostent *local;
|
||||||
struct qsockaddr addr;
|
struct qsockaddr addr;
|
||||||
|
@ -59,18 +59,18 @@ sys_socket_t UDP_Init (void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buff[MAXHOSTNAMELEN - 1] = 0;
|
buff[MAXHOSTNAMELEN - 1] = 0;
|
||||||
|
#ifdef PLATFORM_OSX
|
||||||
// ericw -- if our hostname ends in ".local" (a macOS thing),
|
// ericw -- if our hostname ends in ".local" (a macOS thing),
|
||||||
// don't bother calling gethostbyname(), because it blocks for a few seconds
|
// don't bother calling gethostbyname(), because it blocks for a few seconds
|
||||||
// and then fails (on my system anyway.)
|
// 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);
|
Con_SafePrintf("UDP_Init: skipping gethostbyname for %s\n", buff);
|
||||||
goto skip_gethostbyname;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
local = gethostbyname(buff);
|
#endif
|
||||||
if (local == NULL)
|
if (!(local = gethostbyname(buff)))
|
||||||
{
|
{
|
||||||
Con_SafePrintf("UDP_Init: gethostbyname failed (%s)\n",
|
Con_SafePrintf("UDP_Init: gethostbyname failed (%s)\n",
|
||||||
hstrerror(h_errno));
|
hstrerror(h_errno));
|
||||||
|
@ -85,7 +85,6 @@ sys_socket_t UDP_Init (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
skip_gethostbyname:
|
|
||||||
if ((net_controlsocket = UDP_OpenSocket(0)) == INVALID_SOCKET)
|
if ((net_controlsocket = UDP_OpenSocket(0)) == INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
Con_SafePrintf("UDP_Init: Unable to open control socket, UDP disabled\n");
|
Con_SafePrintf("UDP_Init: Unable to open control socket, UDP disabled\n");
|
||||||
|
@ -98,9 +97,8 @@ skip_gethostbyname:
|
||||||
|
|
||||||
UDP_GetSocketAddr (net_controlsocket, &addr);
|
UDP_GetSocketAddr (net_controlsocket, &addr);
|
||||||
strcpy(my_tcpip_address, UDP_AddrToString (&addr));
|
strcpy(my_tcpip_address, UDP_AddrToString (&addr));
|
||||||
colon = strrchr (my_tcpip_address, ':');
|
tst = strrchr(my_tcpip_address, ':');
|
||||||
if (colon)
|
if (tst) *tst = 0;
|
||||||
*colon = 0;
|
|
||||||
|
|
||||||
Con_SafePrintf("UDP Initialized\n");
|
Con_SafePrintf("UDP Initialized\n");
|
||||||
tcpipAvailable = true;
|
tcpipAvailable = true;
|
||||||
|
|
Loading…
Reference in New Issue