Skip to content
Snippets Groups Projects
Commit 1463958d authored by Deucе's avatar Deucе :ok_hand_tone4:
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 01fc91c8
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment