Skip to content

Exclude internal events from IoHandler.run() return value in epoll, io_uring and kqueue (#16848) - #16923

Merged
chrisvest merged 1 commit into
netty:5.0from
chrisvest:5.0-wakeup
Jun 9, 2026
Merged

chrisvest merged 1 commit into
netty:5.0from
chrisvest:5.0-wakeup

Conversation

@chrisvest

Copy link
Copy Markdown
Member

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)

…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 chrisvest added this to the 5.0.0.Final milestone Jun 8, 2026
@chrisvest
chrisvest enabled auto-merge (squash) June 8, 2026 16:14
@chrisvest
chrisvest disabled auto-merge June 8, 2026 22:48
@chrisvest
chrisvest enabled auto-merge (squash) June 9, 2026 00:12
@chrisvest
chrisvest merged commit 9c28333 into netty:5.0 Jun 9, 2026
21 of 23 checks passed
@chrisvest
chrisvest deleted the 5.0-wakeup branch June 10, 2026 22:26
@normanmaurer normanmaurer mentioned this pull request Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants