forked from Mirrors/openclonk
C4NetIO: Endless polls cut short by cheap hack
parent
3ce7d7ae7f
commit
09e1a47cf9
|
@ -385,6 +385,13 @@ bool C4NetIOTCP::CloseBroadcast()
|
|||
return true;
|
||||
}
|
||||
|
||||
static int fix_poll_timeout(int timeout) {
|
||||
if (timeout < 0 || timeout > 1000)
|
||||
return 1000;
|
||||
else
|
||||
return timeout;
|
||||
}
|
||||
|
||||
bool C4NetIOTCP::Execute(int iMaxTime, pollfd *fds) // (mt-safe)
|
||||
{
|
||||
// security
|
||||
|
@ -400,6 +407,8 @@ bool C4NetIOTCP::Execute(int iMaxTime, pollfd *fds) // (mt-safe)
|
|||
WSANETWORKEVENTS wsaEvents;
|
||||
#else
|
||||
|
||||
iMaxTime = fix_poll_timeout(iMaxTime);
|
||||
|
||||
std::vector<pollfd> fdvec;
|
||||
std::map<SOCKET, const pollfd*> fdmap;
|
||||
if (!fds)
|
||||
|
@ -1529,6 +1538,7 @@ bool C4NetIOSimpleUDP::Execute(int iMaxTime, pollfd *)
|
|||
// The FIONREAD ioctl call takes an int on unix
|
||||
int iMaxMsgSize;
|
||||
#endif
|
||||
iMaxTime = fix_poll_timeout(iMaxTime);
|
||||
if (::ioctlsocket(sock, FIONREAD, &iMaxMsgSize) == SOCKET_ERROR)
|
||||
{
|
||||
SetError("Could not determine the amount of data that can be read from socket", true);
|
||||
|
|
Loading…
Reference in New Issue