Skip to content

Commit

Permalink
Only apple sets data to 1 on write events...
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Mar 19, 2024
1 parent b45e2af commit bac4a68
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/linux/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions test/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bac4a68

Please sign in to comment.