Skip to content

fix(kqueue): preserve EV_CLEAR on EVFILT_USER notify and reset flag on EINTR#265

Open
paddor wants to merge 1 commit into
smol-rs:masterfrom
paddor:fix/kqueue-evfilt-user-clear
Open

fix(kqueue): preserve EV_CLEAR on EVFILT_USER notify and reset flag on EINTR#265
paddor wants to merge 1 commit into
smol-rs:masterfrom
paddor:fix/kqueue-evfilt-user-clear

Conversation

@paddor

@paddor paddor commented May 23, 2026

Copy link
Copy Markdown

Two bugs in the kqueue EVFILT_USER notification path:

  1. notify() drops EV_CLEAR: The trigger changelist uses EV_ADD without EV_CLEAR. Since the filter was originally registered with EV_CLEAR (edge-triggered auto-reset), the EV_ADD in notify() silently switches it to level-triggered mode. After the first notification, every subsequent kevent() wait returns the stale event immediately, causing a busy loop.

  2. EINTR swallows concurrent notification: When kevent() returns EINTR, the interrupted call may have already consumed the EVFILT_USER event from a concurrent notify(). The retry loop clears events but does not reset the notified flag, so notify() believes its event is still pending and skips re-triggering. The waiter never wakes.

@paddor paddor force-pushed the fix/kqueue-evfilt-user-clear branch from e39722e to b6d2b6c Compare May 24, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant