diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2011-04-18 15:44:17 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2011-04-18 15:44:17 +0400 |
commit | 0077cd1016c8414f6175f8e94f97be9ea4506bea (patch) | |
tree | 0c466b05d7bcef31b5bcd68006e8c4f92e2a650b /winsup/cygwin/poll.cc | |
parent | 7c8126eb3e2e637eec97e0a2af760a1b7b3f3926 (diff) |
* fhandler_socket.cc (fhandler_socket::evaluate_events): Handle the
FD_CLOSE event specially when called from accept. Explain why.
(fhandler_socket::shutdown): Fake success on not-connected socket and
trigger socket event if the read side of a socket is affected. Explain
why.
* poll.cc (poll): Check for saw_shutdown_read on sockets to generate
POLLHUP as well.
Diffstat (limited to 'winsup/cygwin/poll.cc')
-rw-r--r-- | winsup/cygwin/poll.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/winsup/cygwin/poll.cc b/winsup/cygwin/poll.cc index b7f452ddb..2e68f3249 100644 --- a/winsup/cygwin/poll.cc +++ b/winsup/cygwin/poll.cc @@ -1,7 +1,7 @@ /* poll.cc. Implements poll(2) via usage of select(2) call. - Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 - Red Hat, Inc. + Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, + 2011 Red Hat, Inc. This file is part of Cygwin. @@ -84,12 +84,16 @@ poll (struct pollfd *fds, nfds_t nfds, int timeout) { if (fds[i].fd >= 0) { - if (cygheap->fdtab.not_open (fds[i].fd)) + fhandler_socket *sock; + + /* Check if the descriptor has been closed, or if shutdown for the + read side has been called on a socket. */ + if (cygheap->fdtab.not_open (fds[i].fd) + || ((sock = cygheap->fdtab[fds[i].fd]->is_socket ()) + && sock->saw_shutdown_read ())) fds[i].revents = POLLHUP; else { - fhandler_socket *sock; - if (FD_ISSET(fds[i].fd, read_fds)) /* This should be sufficient for sockets, too. Using MSG_PEEK, as before, can be considered dangerous at |