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
This commit is contained in:
parent
919d519cbb
commit
1481446aae
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user