Commit 2890ff74 authored by Deucе's avatar Deucе 👌🏾
Browse files

A poll() failure with EINTR does not mean a socket is closed.

This won't impact Synchronet as it has a separate signal handling
thread, but we still need to behave properly for processes that
don't.  I'm also saying that ENOMEM does not indicate a disconnection,
though it may be better to pretend it was disconnected...
parent 85f5df80
Pipeline #1593 passed with stage
in 14 minutes and 33 seconds
......@@ -362,6 +362,12 @@ BOOL socket_check(SOCKET sock, BOOL* rd_p, BOOL* wr_p, DWORD timeout)
if (pfd.revents & (POLLERR | POLLHUP | POLLNVAL))
return FALSE;
}
if (j == -1) {
if (errno == EINTR || errno == ENOMEM)
return TRUE;
}
return FALSE;
#endif
}
......@@ -489,10 +495,15 @@ BOOL socket_recvdone(SOCKET sock, int timeout)
pfd.fd = sock;
pfd.events = POLLIN;
if (poll(&pfd, 1, timeout) == 1) {
if (pfd.revents & POLLIN)
return FALSE;
return TRUE;
switch (poll(&pfd, 1, timeout)) {
case 1:
if (pfd.revents & POLLIN)
return FALSE;
return TRUE;
case -1:
if (errno == EINTR || errno == ENOMEM)
return FALSE;
return TRUE;
}
return FALSE;
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment