diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2002-08-29 09:41:00 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2002-08-29 09:41:00 +0000 |
commit | 7382e593a01ee81cea5df91a77a9868281de8c04 (patch) | |
tree | 9fc6e35fd51738d94c9f32c34071b3fffc05a0c2 | |
parent | edb983c141cd64a22815c3a86f84f14fd5762542 (diff) | |
download | cygnal-7382e593a01ee81cea5df91a77a9868281de8c04.tar.gz cygnal-7382e593a01ee81cea5df91a77a9868281de8c04.tar.bz2 cygnal-7382e593a01ee81cea5df91a77a9868281de8c04.zip |
* poll.cc (poll): Peek sockets ready for read to see if there's
actually data.
-rw-r--r-- | winsup/cygwin/ChangeLog | 6 | ||||
-rw-r--r-- | winsup/cygwin/poll.cc | 23 |
2 files changed, 28 insertions, 1 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9036d0387..5c6b53e4b 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2002-08-29 Boris Schaeling <boriss@web.de> + Corinna Vinschen <corinna@vinschen.de> + + * poll.cc (poll): Peek sockets ready for read to see if there's + actually data. + 2002-08-28 Christopher Faylor <cgf@redhat.com> * cygthread.cc (hthreads): Remove unneeded global. diff --git a/winsup/cygwin/poll.cc b/winsup/cygwin/poll.cc index 89a3124d1..36c61cfcc 100644 --- a/winsup/cygwin/poll.cc +++ b/winsup/cygwin/poll.cc @@ -11,6 +11,7 @@ #include "winsup.h" #include <sys/time.h> #include <sys/poll.h> +#include <sys/socket.h> #include <errno.h> #include <stdlib.h> #include "security.h" @@ -85,7 +86,27 @@ poll (struct pollfd *fds, unsigned int nfds, int timeout) else { if (FD_ISSET(fds[i].fd, read_fds)) - fds[i].revents |= POLLIN; + { + char peek[1]; + fhandler_socket *sock = + cygheap->fdtab[fds[i].fd]->is_socket (); + if (!sock) + fds[i].revents |= POLLIN; + else + switch (sock->recvfrom (peek, sizeof(peek), MSG_PEEK, + NULL, NULL)) + { + case -1: /* Something weird happened */ + fds[i].revents |= POLLERR; + break; + case 0: /* Closed on the read side. */ + fds[i].revents |= POLLHUP; + break; + default: + fds[i].revents |= POLLIN; + break; + } + } if (FD_ISSET(fds[i].fd, write_fds)) fds[i].revents |= POLLOUT; if (FD_ISSET(fds[i].fd, except_fds)) |