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

Kyle Evans <kev...@freebsd.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kev...@freebsd.org
         Resolution|---                         |Works As Intended
             Status|New                         |Closed

--- Comment #2 from Kyle Evans <kev...@freebsd.org> ---
The root of the problem here is that EV_RECEIPT on the first event will halt
processing because nevents == 0; this is common amongst {Net,Free,Open}BSD, at
least.

EV_RECEIPT should only be set on the last event you're passing in to get the
semantics you're wanting; if an error happens on any event before that one
you'll get the same EV_ERROR return (if feasible) and will not drain the queue.
If no error happens, you'll hit that one and still not drain the queue because
EV_RECEIPT is set.

Here's the diff I applied to your example:

<<<EOF
--- kq.c.orig   2020-04-21 20:02:08.123750000 -0500
+++ kq.c        2020-04-21 20:02:24.577357000 -0500
@@ -108,7 +108,7 @@

                kq = kqueue();

-               EV_SET(kev, client, EVFILT_READ, EV_ADD | EV_CLEAR |
EV_RECEIPT, 0, 0, 0);
+               EV_SET(kev, client, EVFILT_READ, EV_ADD | EV_CLEAR, 0, 0, 0);
                EV_SET(kev + 1, client, EVFILT_WRITE, EV_ADD | EV_CLEAR |
EV_RECEIPT, 0, 0, 0);
                kevent(kq, kev, 2, NULL, 0, NULL);

@@ -131,7 +131,7 @@

                kq = kqueue();

-               EV_SET(kev, client, EVFILT_WRITE, EV_ADD | EV_CLEAR |
EV_RECEIPT, 0, 0, 0);
+               EV_SET(kev, client, EVFILT_WRITE, EV_ADD | EV_CLEAR, 0, 0, 0);
                EV_SET(kev + 1, client, EVFILT_READ, EV_ADD | EV_CLEAR |
EV_RECEIPT, 0, 0, 0);
                kevent(kq, kev, 2, NULL, 0, NULL);

EOF

I'm tentatively closing this as "works as intended," but please do feel free to
re-open if you believe a change is necessary here after this explanation.

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"

Reply via email to