From owner-freebsd-bugs@freebsd.org Sat Sep 26 09:04:19 2015 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9AFD7A09847 for ; Sat, 26 Sep 2015 09:04:19 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6E74EDD2 for ; Sat, 26 Sep 2015 09:04:19 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id t8Q94JjO060718 for ; Sat, 26 Sep 2015 09:04:19 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 203366] kevent: EV_CLEAR on fifo does not work correctly Date: Sat, 26 Sep 2015 09:04:19 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 10.2-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: mt@markoturk.info X-Bugzilla-Status: New X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Sep 2015 09:04:19 -0000 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@FreeBSD.org Reporter: mt@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.