- Fix for nonblocking sockets using WSAEventSelect() (patch from Ove
Kaaven).
- Changed WSAEnumNetworkEvents() so it only returns events that the
application is looking for.
- Changed sock_poll_event() to interpret a POLLIN event with zero
bytes waiting to be read as a POLLHUP.
diff --git a/server/sock.c b/server/sock.c
index b5c77a8..070146d 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -84,7 +84,7 @@
if (sock->obj.select == -1) {
/* previously unconnected socket, is this reselect supposed to connect it? */
- if (!sock->state) return;
+ if (!(sock->state & ~WS_FD_NONBLOCKING)) return;
/* ok, it is, attach it to the wineserver's main poll loop */
add_select_user( &sock->obj );
}
@@ -161,12 +161,20 @@
/* normal data flow */
if (event & POLLIN)
{
- /* incoming data */
- sock->pmask |= FD_READ;
- sock->hmask |= FD_READ;
- sock->errors[FD_READ_BIT] = 0;
- if (debug_level)
- fprintf(stderr, "socket %d is readable\n", sock->obj.fd );
+ char dummy;
+
+ /* Linux 2.4 doesn't report POLLHUP if only one side of the socket
+ * has been closed, so we need to check for it explicitly here */
+ if (!recv( sock->obj.fd, &dummy, 1, MSG_PEEK )) event = POLLHUP;
+ else
+ {
+ /* incoming data */
+ sock->pmask |= FD_READ;
+ sock->hmask |= FD_READ;
+ sock->errors[FD_READ_BIT] = 0;
+ if (debug_level)
+ fprintf(stderr, "socket %d is readable\n", sock->obj.fd );
+ }
}
if (event & POLLOUT)
{