Fix FreeBSD: EVFILT_USER wakeup lost when event loop is idle - #260
Fix FreeBSD: EVFILT_USER wakeup lost when event loop is idle#260mstdokumaci wants to merge 1 commit into
Conversation
Register the EVFILT_USER async filter persistently (EV_ADD|EV_CLEAR) in us_internal_async_set and trigger it with a bare NOTE_TRIGGER in us_internal_async_wakeup. The previous per-wakeup EV_ADD|EV_ONESHOT never fires in an idle loop on FreeBSD: the trigger is silently lost, and the loop only iterates on unrelated later activity, delaying cross-thread wakeups. Epoll path untouched.
|
Does this issue exist for macOS as well? |
No, it is only reproducible on FreeBSD; on macOS, eventing works fine with or without this fix. |
|
Okay well then it's not really a bug issue, but a request to support FreeBSD, which we don't. There isn't even any FreeBSD runners on GitHub Actions so we cannot even easily run tests on that platform and Node.js do not support it and pretty sure Deno & Bun don't either. |
Agreed, I actually came across this while runinng bun on FreeBSD, because bun have a binary for FreeBSD on the release page: https://github.com/oven-sh/bun/releases . Do you think it is worth adding a bun on FreeBSD action runner? I can give it a try and see what else comes out. Your call, since FreeBSD is not oficially supported. |
Problem
On FreeBSD,
us_internal_async_wakeupre-registered theEVFILT_USERfilter on every call withEV_ADD|EV_ONESHOT. That registration never fires while the loop is idle inkevent(): the trigger is silently lost, and the wakeup is only picked up once something unrelated causes the loop to iterate again — delaying cross-thread wakeups.Fix
Register
EVFILT_USERonce, persistently, inus_internal_async_setwithEV_ADD|EV_CLEAR.us_internal_async_wakeupthen just fires a bareNOTE_TRIGGERagainst the existing registration instead of re-adding the filter each time.Scope
epoll is untouched — this only affects the kqueue backend.