Refactor async poll()/select() onto a per-inode readiness wait-queue#27226
Merged
Conversation
Move the readiness wait-queue onto FSNode (addListener/notifyListeners) so dup'd fds share one queue, and rewrite the suspending poll() path (readPollfds/writePollfds/pollWait) on top of it. Producers (SOCKFS, PIPEFS) now notify the node on readiness transitions, and close() wakes waiters with POLLNVAL. The stream_ops.poll backend handler signature changes from poll(stream, timeout) to poll(stream) returning the current readiness mask.
f5b9a75 to
38d299d
Compare
sbc100
reviewed
Jul 1, 2026
sbc100
left a comment
Collaborator
There was a problem hiding this comment.
Great! Thanks for splitting this out.
lgtm with some comments
sbc100
reviewed
Jul 1, 2026
54603a4 to
6d38401
Compare
sbc100
approved these changes
Jul 1, 2026
sbc100
reviewed
Jul 1, 2026
sbc100
approved these changes
Jul 1, 2026
sbc100
reviewed
Jul 1, 2026
sbc100
reviewed
Jul 1, 2026
sbc100
reviewed
Jul 1, 2026
sbc100
reviewed
Jul 1, 2026
sbc100
reviewed
Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This refactors out a partial base from #27207.
Move the readiness wait-queue onto FSNode (addListener/notifyListeners) so dup'd fds share one queue, and rewrite the suspending poll() path (readPollfds/writePollfds/pollWait) on top of it. Producers (SOCKFS, PIPEFS) now notify the node on readiness transitions, and close() wakes waiters with POLLNVAL.
addListener(cb, exclusive)/notifyListeners(flags)— a per-inode Set of listener entries. It lives on the node (not the fd) so dup'd fds share one queue. Only nodes with real readiness (sockets, pipes) ever populate it; always-ready types (regular files, ttys) never touch it.poll()path is rewritten on top of it (readPollfds/writePollfds/pollWait/pollOne), replacing the old doPollAsync + makeNotifyCallback machinery.PIPEFSon writes,SOCKFSvia its emit bridge, andclose()wakes any waiter withPOLLNVAL.POLLRDHUP(only a fully closed connection isPOLLHUP), and a queued client makes a listening socketPOLLIN.The stream_ops.poll backend handler signature changes from
poll(stream, timeout)topoll(stream)returning the current readiness mask.Note: the
exclusiveparameter onaddListenerand the round-robin wakeup path innotifyListenersare deliberately layered in here as groundwork for the EPOLLEXCLUSIVE handling that lands in the epoll followup (#27207). No caller passesexclusivein this PR yet, so that branch is currently inert — it's included now to keep the wait-queue API stable across the split.