diff options
author | rwatson <rwatson@FreeBSD.org> | 2005-09-12 10:16:18 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2005-09-12 10:16:18 +0000 |
commit | 1481446aae3f57f2a3c6facaaf98f0c864b1416d (patch) | |
tree | f82a889670fb21da1ddade25b21789bf875ab183 /sys/fs/fifofs | |
parent | 919d519cbbf1563e57778c33e1f384f2a5e7d871 (diff) | |
download | FreeBSD-src-1481446aae3f57f2a3c6facaaf98f0c864b1416d.zip FreeBSD-src-1481446aae3f57f2a3c6facaaf98f0c864b1416d.tar.gz |
Only poll the fifo for read events if the fifo is attached to a readable
file descriptor. Otherwise, the read end of a fifo might return that it
is writable (which it isn't).
Only poll the fifo for write events if the fifo attached to a writable
file descriptor. Otherwise, the write end of a fifo might return that
it is readable (which it isn't).
In the event that a file is FREAD|FWRITE (which is allowed by POSIX, but
has undefined behavior), we poll for both.
MFC after: 3 days
Diffstat (limited to 'sys/fs/fifofs')
-rw-r--r-- | sys/fs/fifofs/fifo_vnops.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/fs/fifofs/fifo_vnops.c b/sys/fs/fifofs/fifo_vnops.c index 4483fdf..f355d5a 100644 --- a/sys/fs/fifofs/fifo_vnops.c +++ b/sys/fs/fifofs/fifo_vnops.c @@ -615,7 +615,7 @@ fifo_poll_f(struct file *fp, int events, struct ucred *cred, struct thread *td) fip = fp->f_data; levents = events & (POLLIN | POLLINIGNEOF | POLLPRI | POLLRDNORM | POLLRDBAND); - if (levents) { + if ((fp->f_flag & FREAD) && levents) { /* * If POLLIN or POLLRDNORM is requested and POLLINIGNEOF is * not, then convert the first two to the last one. This @@ -641,7 +641,7 @@ fifo_poll_f(struct file *fp, int events, struct ucred *cred, struct thread *td) } } levents = events & (POLLOUT | POLLWRNORM | POLLWRBAND); - if (levents) { + if ((fp->f_flag & FWRITE) && levents) { filetmp.f_data = fip->fi_writesock; filetmp.f_cred = cred; if (filetmp.f_data) { |