Skip to content

test(libkernel): wait for the looped-back datagram when polling a reused descriptor - #23266

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Romannachwievor:test/guest-poll-reused-udp-wait
Nov 18, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Romannachwievor:test/guest-poll-reused-udp-wait

Conversation

@Romannachwievor

Copy link
Copy Markdown
Contributor

What

ReusedDescriptorNumberIsPolledFresh in guest_poll sends one byte on a UDP socket connected to itself on 127.0.0.1 and then polls it for POLLIN with a timeout of 0. On macOS the looped-back datagram isn't always readable the moment send returns, so the poll sometimes returns 0 and the test aborts at that line.

The check is about the reused descriptor number being looked up fresh, not about how fast loopback delivery is. So the poll now waits up to 1000 ms. It returns as soon as the byte arrives, so a host where it is already readable doesn't wait at all. The select half of the same check in GuestSelect.cpp already waits with GuestTimeval second{1, 0}.

On macOS main doesn't reach this check today: guest_poll aborts earlier in PollsAResetStream (line 391), which #20161 fixes. With #20161 applied, this check becomes the next failure.

Tested

Apple M1, macOS 26.5, Apple clang 21.0.0, x86_64 Release under Rosetta 2, main 245210b07e with #17425 and #11049 (needed for the macOS build):

tree guest_poll
with #20161, timeout 0 passed 11 of 16, the 5 failures all at this poll
without #20161, line 391 skipped, timeout 0 passed 10 of 12, the 2 failures at this poll
with #20161 and this change passed 59 of 60

The one failure in the last row came from the first batch of 20, which didn't record a line. A rerun of 40 with line output had no failures, so I can't say where it came from.

  • Not run on Linux or Windows. The poll only waits there if the byte isn't readable yet.
  • python3 tools/check_conventions.py: passed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)

@PrivacyOnion PrivacyOnion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 2ce8e34736:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_poll_tests built cleanly.
  • CTest (guest_poll):
    1/1 Test #5641: guest_poll .......................   Passed    4.82 sec
    100% tests passed, 0 tests failed out of 1
    
  • Code reading:
    • Verified that poll_nid_postfix timeout parameter in milliseconds (1000 ms) safely accommodates loopback datagram delivery latency on non-instantaneous host network stacks without hanging indefinitely.
    • Confirmed that GuestPollDescriptor entry retains valid poll flags (events = In) and correctly captures revents & In upon arrival of the looped-back byte.
    • Checked that ReusedDescriptorNumberIsPolledFresh socket lifecycle (bind, connect, send, poll, recv, close) remains sound, properly draining the datagram and closing all file descriptors.
    • Verified AGENTS.md compliance: no comments were added, no conventions or git diff errors were triggered, and mechanical checks passed cleanly.

Looks Good To Me

@oneandonlydean
oneandonlydean merged commit b7cc046 into boykopovar:main Nov 18, 2026
13 checks passed
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.

3 participants