FreeBSD Bugzilla – Attachment 190730 Details for
Bug 203366
kevent: EV_CLEAR on fifo does not work correctly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch for FIFO related poll/kqueue issues
fifo-kqueue-issues.patch (text/plain), 2.84 KB, created by
Jan Kokemüller
on 2018-02-17 11:52:06 UTC
(
hide
)
Description:
patch for FIFO related poll/kqueue issues
Filename:
MIME Type:
Creator:
Jan Kokemüller
Created:
2018-02-17 11:52:06 UTC
Size:
2.84 KB
patch
obsolete
>diff --git a/sys/fs/fifofs/fifo_vnops.c b/sys/fs/fifofs/fifo_vnops.c >index 96dd05a18323..a39d559631bc 100644 >--- a/sys/fs/fifofs/fifo_vnops.c >+++ b/sys/fs/fifofs/fifo_vnops.c >@@ -171,8 +171,10 @@ fifo_open(ap) > fip->fi_rgen++; > if (fip->fi_readers == 1) { > fpipe->pipe_state &= ~PIPE_EOF; >- if (fip->fi_writers > 0) >+ if (fip->fi_writers > 0) { > wakeup(&fip->fi_writers); >+ pipeselwakeup(fpipe); >+ } > } > fp->f_seqcount = fpipe->pipe_wgen - fip->fi_writers; > } >@@ -187,8 +189,10 @@ fifo_open(ap) > fip->fi_wgen++; > if (fip->fi_writers == 1) { > fpipe->pipe_state &= ~PIPE_EOF; >- if (fip->fi_readers > 0) >+ if (fip->fi_readers > 0) { > wakeup(&fip->fi_readers); >+ pipeselwakeup(fpipe); >+ } > } > } > if ((ap->a_mode & O_NONBLOCK) == 0) { >diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c >index 469f5243635d..57fa296bfd69 100644 >--- a/sys/kern/sys_pipe.c >+++ b/sys/kern/sys_pipe.c >@@ -823,7 +823,13 @@ pipe_read(fp, uio, active_cred, flags, td) > } > } > >- if ((rpipe->pipe_buffer.size - rpipe->pipe_buffer.cnt) >= PIPE_BUF) >+ /* >+ * Only wake up writers if there was actually something read. >+ * Otherwise, when calling read(2) at EOF, a spurious wakeup occurs >+ * that might lead to issues like PR 203366. >+ */ >+ if (nread > 0 && >+ (rpipe->pipe_buffer.size - rpipe->pipe_buffer.cnt) >= PIPE_BUF) > pipeselwakeup(rpipe); > > PIPE_UNLOCK(rpipe); >@@ -1461,7 +1467,8 @@ pipe_poll(fp, events, active_cred, td) > > if ((events & POLLINIGNEOF) == 0) { > if (rpipe->pipe_state & PIPE_EOF) { >- revents |= (events & (POLLIN | POLLRDNORM)); >+ if (fp->f_flag & FREAD) >+ revents |= (events & (POLLIN | POLLRDNORM)); > if (wpipe->pipe_present != PIPE_ACTIVE || > (wpipe->pipe_state & PIPE_EOF)) > revents |= POLLHUP; >@@ -1788,23 +1795,22 @@ filt_pipedetach(struct knote *kn) > static int > filt_piperead(struct knote *kn, long hint) > { >+ struct file *fp = kn->kn_fp; > struct pipe *rpipe = kn->kn_hook; >- struct pipe *wpipe = rpipe->pipe_peer; >- int ret; > > PIPE_LOCK_ASSERT(rpipe, MA_OWNED); > kn->kn_data = rpipe->pipe_buffer.cnt; > if ((kn->kn_data == 0) && (rpipe->pipe_state & PIPE_DIRECTW)) > kn->kn_data = rpipe->pipe_map.cnt; > >- if ((rpipe->pipe_state & PIPE_EOF) || >- wpipe->pipe_present != PIPE_ACTIVE || >- (wpipe->pipe_state & PIPE_EOF)) { >+ if ((rpipe->pipe_state & PIPE_EOF) && >+ !((rpipe->pipe_state & PIPE_NAMED) && >+ (fp->f_seqcount == rpipe->pipe_wgen))) { > kn->kn_flags |= EV_EOF; > return (1); > } >- ret = kn->kn_data > 0; >- return ret; >+ kn->kn_flags &= ~EV_EOF; >+ return (kn->kn_data > 0); > } > > /*ARGSUSED*/ >@@ -1821,6 +1827,7 @@ filt_pipewrite(struct knote *kn, long hint) > kn->kn_flags |= EV_EOF; > return (1); > } >+ kn->kn_flags &= ~EV_EOF; > kn->kn_data = (wpipe->pipe_buffer.size > 0) ? > (wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt) : PIPE_BUF; > if (wpipe->pipe_state & PIPE_DIRECTW)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 203366
:
162301
|
167574
|
188967
| 190730