Don't check for new events if KEVENT_FLAG_ERROR_EVENTS is given

We were dropping events before because libdispatch calls kevent with this flag to update a knote without checking for new events; when it did that and we handed it some new events, it would ignore them since they didn't contain `EV_ERROR`, which meant those events were lost forever.
This commit is contained in:
Ariel Abreu 2022-02-25 16:15:41 -05:00
parent 76d8aa3dce
commit 9b4eecbd88
No known key found for this signature in database
GPG Key ID: D67AE16CCEA85B70

View File

@ -381,7 +381,7 @@ kevent64_impl(int kqfd, const struct kevent64_s *changelist, int nchanges,
*/
if (nevents > MAX_KEVENT)
nevents = MAX_KEVENT;
if (nevents > 0) {
if ((flags & KEVENT_FLAG_ERROR_EVENTS) == 0 && nevents > 0) {
const struct timespec* ts = (flags & KEVENT_FLAG_IMMEDIATE) ? (&timeout_zero) : timeout;
again:
rv = kqops.kevent_wait(kq, nevents, ts);