Repository navigation
Exclude internal events from IoHandler.run() return value in epoll, io_uring and kqueue (#16848) - #16923
Merged
Conversation
…o_uring and kqueue (netty#16848) Motivation: IoHandler.run() contract returns the number of IoHandle instances for which I/O was handled. NIO correctly returns 0 for wakeup-only events, but epoll counted all epoll_wait events (including eventfd and timerfd), io_uring counted all completions (including eventfd and ring fd), and kqueue counted EVFILT_USER wakeup events. Modifications: Epoll: pack real I/O count and timer flag into processReady() return value. Each real I/O event adds 2, timer fired ORs 1. Caller unpacks via shift and mask. io_uring: change CompletionCallback.handle() to return boolean indicating whether the completion is real I/O. CompletionQueue.process() returns a packed long with total completions in upper 32 bits and real I/O count in lower 32 bits. processCompletionsAndHandleOverflow() unpacks and returns only the real I/O count. KQueue: processReady() returns the count of real I/O events, excluding EVFILT_USER and EV_ERROR. Add AbstractIoHandlerEventCountTest with shared tests for all transports (NIO, epoll, io_uring, kqueue) verifying: timer returns 0, wakeup returns 0, and scheduled tasks are not inflated by internal events. Update IoHandler.run() Javadoc to explicitly state that internal events must not be included in the return value. Result: All transports now consistently return 0 from run() when only internal events occurred, matching the IoHandler contract. (cherry picked from commit 8e7f51d)
chrisvest
enabled auto-merge (squash)
June 8, 2026 16:14
chrisvest
disabled auto-merge
June 8, 2026 22:48
chrisvest
enabled auto-merge (squash)
June 9, 2026 00:12
Closed
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.
Motivation:
IoHandler.run() contract returns the number of IoHandle instances for which I/O was handled. NIO correctly returns 0 for wakeup-only events, but epoll counted all epoll_wait events (including eventfd and timerfd), io_uring counted all completions (including eventfd and ring fd), and kqueue counted EVFILT_USER wakeup events.
Modifications:
Epoll: pack real I/O count and timer flag into processReady() return value. Each real I/O event adds 2, timer fired ORs 1. Caller unpacks via shift and mask.
io_uring: change CompletionCallback.handle() to return boolean indicating whether the completion is real I/O. CompletionQueue.process() returns a packed long with total completions in upper 32 bits and real I/O count in lower 32 bits. processCompletionsAndHandleOverflow() unpacks and returns only the real I/O count.
KQueue: processReady() returns the count of real I/O events, excluding EVFILT_USER and EV_ERROR.
Add AbstractIoHandlerEventCountTest with shared tests for all transports (NIO, epoll, io_uring, kqueue) verifying: timer returns 0, wakeup returns 0, and scheduled tasks are not inflated by internal events.
Update IoHandler.run() Javadoc to explicitly state that internal events must not be included in the return value.
Result:
All transports now consistently return 0 from run() when only internal events occurred, matching the IoHandler contract.
(cherry picked from commit 8e7f51d)