mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Merge branch 'winsock-error-handling-fixes' into 'master'
Winsock error handling fixes See merge request STJr/SRB2!303
This commit is contained in:
commit
7cc5caf69c
1 changed files with 34 additions and 3 deletions
37
src/i_tcp.c
37
src/i_tcp.c
|
@ -262,6 +262,33 @@ static void wattcp_outch(char s)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_WINSOCK
|
||||||
|
// stupid microsoft makes things complicated
|
||||||
|
static char *get_WSAErrorStr(int e)
|
||||||
|
{
|
||||||
|
static char buf[256]; // allow up to 255 bytes
|
||||||
|
|
||||||
|
buf[0] = '\0';
|
||||||
|
|
||||||
|
FormatMessageA(
|
||||||
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||||
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
|
NULL,
|
||||||
|
(DWORD)e,
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
|
(LPTSTR)buf,
|
||||||
|
sizeof (buf),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (!buf[0]) // provide a fallback error message if no message is available for some reason
|
||||||
|
sprintf(buf, "Unknown error");
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
#undef strerror
|
||||||
|
#define strerror get_WSAErrorStr
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef USE_WINSOCK2
|
#ifdef USE_WINSOCK2
|
||||||
#define inet_ntop inet_ntopA
|
#define inet_ntop inet_ntopA
|
||||||
#define HAVE_NTOP
|
#define HAVE_NTOP
|
||||||
|
@ -759,9 +786,13 @@ static void SOCK_Send(void)
|
||||||
&clientaddress[doomcom->remotenode].any, d);
|
&clientaddress[doomcom->remotenode].any, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == ERRSOCKET && errno != ECONNREFUSED && errno != EWOULDBLOCK)
|
if (c == ERRSOCKET)
|
||||||
I_Error("SOCK_Send, error sending to node %d (%s) #%u: %s", doomcom->remotenode,
|
{
|
||||||
SOCK_GetNodeAddress(doomcom->remotenode), errno, strerror(errno));
|
int e = errno; // save error code so it can't be modified later
|
||||||
|
if (e != ECONNREFUSED && e != EWOULDBLOCK)
|
||||||
|
I_Error("SOCK_Send, error sending to node %d (%s) #%u: %s", doomcom->remotenode,
|
||||||
|
SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue