[Bug 203366] kevent: EV_CLEAR on fifo does not work correctly

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sat Sep 26 09:04:19 UTC 2015


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203366

            Bug ID: 203366
           Summary: kevent: EV_CLEAR on fifo does not work correctly
           Product: Base System
           Version: 10.2-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: freebsd-bugs at FreeBSD.org
          Reporter: mt at markoturk.info

Hi,

according to kqueue(2) man page for EVFILT_READ on a fifo:
"When the last writer disconnects, the filter will set EV_EOF in flags. This
may be cleared by passing in EV_CLEAR, at which point the filter will resume
waiting for data to become available before returning."

But, EV_CLEAR on fifo does not work (EV_EOF is returned).

To reproduce (tail uses kevent and EV_CLEAR internally):
mkfifo foo
tail -f foo
(in another terminal:) echo xxx > foo
After this, top process uses all CPU.

I tried to fix the bug. After applying this patch the problem is not visible,
but I'm not sure if this is the correct solution:

Index: sys/kern/sys_pipe.c
===================================================================
--- sys/kern/sys_pipe.c (revision 288220)
+++ sys/kern/sys_pipe.c (working copy)
@@ -1791,9 +1791,10 @@
        if ((kn->kn_data == 0) && (rpipe->pipe_state & PIPE_DIRECTW))
                kn->kn_data = rpipe->pipe_map.cnt;

-       if ((rpipe->pipe_state & PIPE_EOF) ||
+       if (!(kn->kn_flags & EV_CLEAR) &&
+           ((rpipe->pipe_state & PIPE_EOF) ||
            wpipe->pipe_present != PIPE_ACTIVE ||
-           (wpipe->pipe_state & PIPE_EOF)) {
+           (wpipe->pipe_state & PIPE_EOF))) {
                kn->kn_flags |= EV_EOF;
                return (1);
        }

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list