GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Don't stop reading domain datagrams after an empty datagram by normanmaurer · Pull Request #18395 · netty/netty

Conversation

@normanmaurer

@normanmaurer normanmaurer commented Nov 13, 2026

Copy link
Copy Markdown
Member

Motivation:

DatagramUnicastTest#testSendEmptyDatagramsInOneFlush fails sporadically on CI for EpollDomainDatagramChannel with received [A, ]: the datagrams that follow an empty one are never delivered.

MaxMessageHandle.continueReading(...) requires totalBytesRead > 0, and a zero-length datagram does not add to it. When a read loop starts with an empty datagram, the loop ends after reading it. Epoll is edge-triggered, so the datagrams still queued in the socket buffer never raise another EPOLLIN and stay unread. Whether this happens depends on how the sender and receiver interleave. EpollDatagramChannel already avoids this with Math.max(1, bytesRead); the domain datagram channels did not.

Modification:

  • EpollDomainDatagramChannel and KQueueDomainDatagramChannel report at least 1 byte to the RecvByteBufAllocator.Handle for an unconnected zero-length datagram, while still using the real size for the buffer's writer index.
  • Add DatagramUnicastTest#testEmptyDatagramStartsReadLoop, which waits for the first read loop to complete so that the next one deterministically starts with an empty datagram.

A zero-length datagram on a connected domain datagram channel is still indistinguishable from EOF because Socket.recv(...) maps 0 to -1. That is not changed here.

Result:

All datagrams are delivered when a read loop starts with an empty datagram on the epoll and kqueue domain datagram channels. No public API change, nothing potentially breaking.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@normanmaurer
Don't stop reading domain datagrams after an empty datagram
184efbd
Motivation:

`DatagramUnicastTest#testSendEmptyDatagramsInOneFlush` fails sporadically on
CI for `EpollDomainDatagramChannel` with `received [A, ]`: the datagrams that
follow an empty one are never delivered.

`DefaultMaxMessagesRecvByteBufAllocator.MaxMessageHandle.continueReading(...)`
requires `totalBytesRead > 0`, and a zero-length datagram does not add to it.
When a read loop starts with an empty datagram, the loop ends after reading it.
Epoll is edge-triggered, so the datagrams still queued in the socket buffer
never raise another `EPOLLIN` and stay unread. Whether this happens depends on
how the sender and receiver interleave. `EpollDatagramChannel` already avoids
this with `Math.max(1, bytesRead)`; the domain datagram channels did not.

Modification:

- `EpollDomainDatagramChannel` and `KQueueDomainDatagramChannel` report at
  least 1 byte to the `RecvByteBufAllocator.Handle` for an unconnected
  zero-length datagram, while still using the real size for the buffer's
  writer index.
- Add `DatagramUnicastTest#testEmptyDatagramStartsReadLoop`, which waits for
  the first read loop to complete so that the next one deterministically
  starts with an empty datagram.

A zero-length datagram on a *connected* domain datagram channel is still
indistinguishable from EOF because `Socket.recv(...)` maps 0 to -1. That is
not changed here.

Result:

All datagrams are delivered when a read loop starts with an empty datagram on
the epoll and kqueue domain datagram channels. No public API change.
@normanmaurer normanmaurer added this to the 4.1.141.Final milestone Nov 13, 2026
@normanmaurer normanmaurer added needs-cherry-pick-4.2 This PR should be cherry-picked to 4.2 once merged. needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. labels Nov 13, 2026
chrisvest
chrisvest approved these changes Nov 13, 2026
View reviewed changes
@chrisvest
chrisvest enabled auto-merge (squash) November 13, 2026 21:31
@testlens-app

testlens-app Bot commented Nov 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 184efbd
▶️ Tests: 43272 executed
🟡 Checks: 22/25 completed


Learn more about TestLens at testlens.app/docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisvest
chrisvest merged commit cf1a2a8 into netty:4.1 Nov 13, 2026
23 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@netty-project-bot

netty-project-bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Could not create auto-port PR.
Got conflicts when cherry-picking onto 5.0.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@netty-project-bot netty-project-bot mentioned this pull request Nov 14, 2026
Auto-port 4.2: Don't stop reading domain datagrams after an empty datagram #18408
Merged
@netty-project-bot

netty-project-bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 4.2: #18408

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs-cherry-pick-4.2 This PR should be cherry-picked to 4.2 once merged. label Nov 14, 2026
normanmaurer added a commit that referenced this pull request Nov 14, 2026
@netty-project-bot @normanmaurer
Auto-port 4.2: Don't stop reading domain datagrams after an empty dat…
09a7227
…agram (#18408)

Auto-port of #18395 to 4.2
Cherry-picked commit: cf1a2a8

---
Motivation:

`DatagramUnicastTest#testSendEmptyDatagramsInOneFlush` fails
sporadically on CI for `EpollDomainDatagramChannel` with `received [A,
]`: the datagrams that follow an empty one are never delivered.

`MaxMessageHandle.continueReading(...)` requires `totalBytesRead > 0`,
and a zero-length datagram does not add to it. When a read loop starts
with an empty datagram, the loop ends after reading it. Epoll is
edge-triggered, so the datagrams still queued in the socket buffer never
raise another `EPOLLIN` and stay unread. Whether this happens depends on
how the sender and receiver interleave. `EpollDatagramChannel` already
avoids this with `Math.max(1, bytesRead)`; the domain datagram channels
did not.

Modification:

- `EpollDomainDatagramChannel` and `KQueueDomainDatagramChannel` report
at least 1 byte to the `RecvByteBufAllocator.Handle` for an unconnected
zero-length datagram, while still using the real size for the buffer's
writer index.
- Add `DatagramUnicastTest#testEmptyDatagramStartsReadLoop`, which waits
for the first read loop to complete so that the next one
deterministically starts with an empty datagram.

A zero-length datagram on a *connected* domain datagram channel is still
indistinguishable from EOF because `Socket.recv(...)` maps 0 to -1. That
is not changed here.

Result:

All datagrams are delivered when a read loop starts with an empty
datagram on the epoll and kqueue domain datagram channels. No public API
change, nothing potentially breaking.

---------

Co-authored-by: Norman Maurer <[email protected]>
@chrisvest

chrisvest commented Nov 16, 2026

Copy link
Copy Markdown
Member

5.0 port #18437

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisvest chrisvest removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Nov 16, 2026
chrisvest added a commit that referenced this pull request Nov 17, 2026
@chrisvest
Don't stop reading domain datagrams after an empty datagram (#18395) (#…
024f01e
…18437)

Motivation:

`DatagramUnicastTest#testSendEmptyDatagramsInOneFlush` fails
sporadically on CI for `EpollDomainDatagramChannel` with `received [A,
]`: the datagrams that follow an empty one are never delivered.

`MaxMessageHandle.continueReading(...)` requires `totalBytesRead > 0`,
and a zero-length datagram does not add to it. When a read loop starts
with an empty datagram, the loop ends after reading it. Epoll is
edge-triggered, so the datagrams still queued in the socket buffer never
raise another `EPOLLIN` and stay unread. Whether this happens depends on
how the sender and receiver interleave. `EpollDatagramChannel` already
avoids this with `Math.max(1, bytesRead)`; the domain datagram channels
did not.

Modification:

- `EpollDomainDatagramChannel` and `KQueueDomainDatagramChannel` report
at least 1 byte to the `RecvByteBufAllocator.Handle` for an unconnected
zero-length datagram, while still using the real size for the buffer's
writer index.
- Add `DatagramUnicastTest#testEmptyDatagramStartsReadLoop`, which waits
for the first read loop to complete so that the next one
deterministically starts with an empty datagram.

A zero-length datagram on a *connected* domain datagram channel is still
indistinguishable from EOF because `Socket.recv(...)` maps 0 to -1. That
is not changed here.

Result:

All datagrams are delivered when a read loop starts with an empty
datagram on the epoll and kqueue domain datagram channels. No public API
change, nothing potentially breaking.

(cherry picked from commit cf1a2a8)

5.0 port notes: on 5.0 the domain datagram channels are merged into
`EpollDatagramChannel` (`epollInReadyUnix`) and `KQueueDatagramChannel`
(the `SocketProtocolFamily.UNIX` branch of `readReady`), so the fix is
applied there. In `KQueueDatagramChannel` it is limited to the UNIX
branch, as on 4.1. The test was adapted to the 5.0 API (`Future<Void>`,
`bind(...).get()`, `convertAnyAddress`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@chrisvest chrisvest chrisvest approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.1.141.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@normanmaurer @netty-project-bot @chrisvest
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.