diff options
author | 2015-05-10 22:35:38 +0000 | |
---|---|---|
committer | 2015-05-10 22:35:38 +0000 | |
commit | b7b44fe5796e416f560eb15867dc757db11a47d6 (patch) | |
tree | 43200ee9dc037d16b8ec01bf207e4f187da941f0 /sys/miscfs | |
parent | Add _bfd_ar_spacepadll() for formatting long long values in archive headers. (diff) | |
download | wireguard-openbsd-b7b44fe5796e416f560eb15867dc757db11a47d6.tar.xz wireguard-openbsd-b7b44fe5796e416f560eb15867dc757db11a47d6.zip |
Set POLLHUP even if no valid events were specified as per POSIX.
Since we use the poll backend for select(2), care must be taken not
to set the fd's bit in writefds in this case. A kernel-only flag,
POLLNOHUP, is used by selscan() to tell the poll backend not to
return POLLHUP on EOF. This is currently only used by fifo_poll().
The fifofs regress now passes. OK guenther@
Diffstat (limited to 'sys/miscfs')
-rw-r--r-- | sys/miscfs/fifofs/fifo_vnops.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/miscfs/fifofs/fifo_vnops.c b/sys/miscfs/fifofs/fifo_vnops.c index 41a6f8ad2f9..4d6a0d7b9f3 100644 --- a/sys/miscfs/fifofs/fifo_vnops.c +++ b/sys/miscfs/fifofs/fifo_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fifo_vnops.c,v 1.46 2015/05/05 20:14:10 millert Exp $ */ +/* $OpenBSD: fifo_vnops.c,v 1.47 2015/05/10 22:35:39 millert Exp $ */ /* $NetBSD: fifo_vnops.c,v 1.18 1996/03/16 23:52:42 christos Exp $ */ /* @@ -296,28 +296,28 @@ fifo_poll(void *v) int revents = 0; /* - * Just return if there are no supported events specified, * FIFOs don't support out-of-band or high priority data. */ if (ap->a_fflag & FREAD) events |= ap->a_events & (POLLIN | POLLRDNORM); if (ap->a_fflag & FWRITE) events |= ap->a_events & (POLLOUT | POLLWRNORM); - if (events == 0) - return (0); if (events & (POLLIN | POLLRDNORM)) { if (soreadable(rso)) revents |= events & (POLLIN | POLLRDNORM); } /* NOTE: POLLHUP and POLLOUT/POLLWRNORM are mutually exclusive */ - if (rso->so_state & SS_ISDISCONNECTED) { + if ((rso->so_state & SS_ISDISCONNECTED) && !(ap->a_events & POLLNOHUP)) { revents |= POLLHUP; } else if (events & (POLLOUT | POLLWRNORM)) { if (sowriteable(wso)) revents |= events & (POLLOUT | POLLWRNORM); } if (revents == 0) { + /* We want to return POLLHUP even if no valid events set. */ + if (events == 0 && !(ap->a_events & POLLNOHUP)) + events = POLLIN; if (events & (POLLIN | POLLRDNORM)) { selrecord(ap->a_p, &rso->so_rcv.sb_sel); rso->so_rcv.sb_flagsintr |= SB_SEL; |