Save the result of errno (aka WSAGetLastError() for WinSock) as soon as possible, to prevent anything in SOCK_GetNodeAddress resetting the value to 0 while trying to print the message for the error itself!

This commit is contained in:
Monster Iestyn 2018-10-27 15:49:04 +01:00
parent ab38e6cebb
commit 3b39a25ade

View file

@ -781,9 +781,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