| Summary: | [PATCH] kevent doesn't notify EV_ENABLE-ed events | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | taketsuru11 | ||||
| Component: | kern | Assignee: | Mark Johnston <markj> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Some People | CC: | hiren, jmg, markj, ngie | ||||
| Priority: | --- | Keywords: | patch | ||||
| Version: | CURRENT | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
Comment on attachment 165759 [details]
reproduce
This program is expected to exit silently, but it prints 'what?!'.
jmg@, can you please take a look to see if this indeed is a regression caused by r274560? We believe we're run in to similar issues internally.. (In reply to Ngie Cooper from comment #3) Indeed. See: https://reviews.freebsd.org/D5307 A commit references this bug: Author: markj Date: Fri Feb 19 01:49:33 UTC 2016 New revision: 295786 URL: https://svnweb.freebsd.org/changeset/base/295786 Log: Ensure that we test the event condition when a disabled kevent is enabled. r274560 modified kqueue_register() to only test the event condition if the corresponding knote is not disabled. However, this check takes place before the EV_ENABLE flag is used to clear the KN_DISABLED flag on the knote, so enabling a previously-disabled kevent would not result in a notification for a triggered event. This change fixes the problem by testing for EV_ENABLED before possibly checking the event condition. This change also updates a kqueue regression test to exercise this case. PR: 206368 Reviewed by: kib Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D5307 Changes: head/sys/kern/kern_event.c head/tests/sys/kqueue/read.c |
Created attachment 165759 [details] reproduce Kevent() doesn't notify an EV_ENABLE-ed event even though the notification condition of the event is satisfied. R274560 introduced this bug. The following patch solves the issue. diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index d41ac96..6584294 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -1284,7 +1284,8 @@ done_ev_add: kn->kn_status |= KN_DISABLED; } - if ((kn->kn_status & KN_DISABLED) == 0) + if ((kev->flags & EV_ENABLE) || + (kn->kn_status & KN_DISABLED) == 0) event = kn->kn_fop->f_event(kn, 0); else event = 0;