From 6ba3f6bb2d088c7b5ffc84a6ed74ad3d525fde37 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sun, 13 Nov 2005 16:24:40 +0000 Subject: [PATCH] * fhandler_socket.cc (fhandler_socket::recvfrom): Just return 0 (EOF) in case of WSAESHUTDOWN. (fhandler_socket::recvmsg): Ditto. * poll.cc (poll): Set revents to POLLIN instead of POLLHUP. Add comment. --- winsup/cygwin/ChangeLog | 7 +++++++ winsup/cygwin/fhandler_socket.cc | 10 ++++++++++ winsup/cygwin/poll.cc | 7 +++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index ae5185eaf..836ad3c7d 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2005-11-13 Corinna Vinschen + + * fhandler_socket.cc (fhandler_socket::recvfrom): Just return 0 (EOF) + in case of WSAESHUTDOWN. + (fhandler_socket::recvmsg): Ditto. + * poll.cc (poll): Set revents to POLLIN instead of POLLHUP. Add comment. + 2005-11-11 Christopher Faylor * cygheap.h (init_cygheap::_gtod): Remove. diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index 79b59ff9b..5ed7d041a 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -1061,6 +1061,11 @@ fhandler_socket::recvfrom (void *ptr, size_t len, int flags, if (WSAGetLastError () == WSAEMSGSIZE) return len; + /* ESHUTDOWN isn't defined for recv in SUSv3. Simply EOF is returned + in this case. */ + if (WSAGetLastError () == WSAESHUTDOWN) + return 0; + set_winsock_errno (); } else @@ -1142,6 +1147,11 @@ fhandler_socket::recvmsg (struct msghdr *msg, int flags, ssize_t tot) if (WSAGetLastError () == WSAEMSGSIZE) return len; + /* ESHUTDOWN isn't defined for recv in SUSv3. Simply EOF is returned + in this case. */ + if (WSAGetLastError () == WSAESHUTDOWN) + return 0; + set_winsock_errno (); } else diff --git a/winsup/cygwin/poll.cc b/winsup/cygwin/poll.cc index 633696c80..0ff62379e 100644 --- a/winsup/cygwin/poll.cc +++ b/winsup/cygwin/poll.cc @@ -118,8 +118,11 @@ poll (struct pollfd *fds, unsigned int nfds, int timeout) else fds[i].revents |= POLLIN; break; - case 0: /* Closed on the read side. */ - fds[i].revents |= POLLHUP; + case 0: /* Closed on the read side... */ + /* ...or shutdown(SHUT_WR) on the write side. + We set revents to POLLHUP until 1.5.18, but + this is semantically borderline. */ + fds[i].revents |= POLLIN; break; default: fds[i].revents |= POLLIN; -- 2.43.5