From bac4a683acdf5fe3d2266509be2979e5c6cf1c7f Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Mon, 18 Mar 2024 22:54:57 -0400 Subject: [PATCH] Only apple sets data to 1 on write events... --- src/linux/write.c | 5 +---- test/write.c | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/linux/write.c b/src/linux/write.c index d450f912..d253604b 100644 --- a/src/linux/write.c +++ b/src/linux/write.c @@ -41,10 +41,7 @@ evfilt_write_copyout(struct kevent *dst, UNUSED int nevents, struct filter *filt /* * Fast path for files... */ - if (src->kn_flags & KNFL_FILE) { - dst->data = 1; /* To match macOS and FreeBSD */ - goto done; - } + if (src->kn_flags & KNFL_FILE) goto done; if (ev->events & EPOLLHUP) dst->flags |= EV_EOF; diff --git a/test/write.c b/test/write.c index 93941e61..2379ed50 100644 --- a/test/write.c +++ b/test/write.c @@ -36,8 +36,10 @@ test_kevent_write_regular_file(struct test_context *ctx) kevent_rv_cmp(0, kevent(ctx->kqfd, &kev, 1, NULL, 0, NULL)); kevent_get(ret, NUM_ELEMENTS(ret), ctx->kqfd, 1); +#ifdef __APPLE__ /* macOS sets this high for some reason */ kev.data = 1; +#endif /* File should appear immediately writable */ kevent_get(NULL, 0, ctx->kqfd, 1);