Skip to content

test(net): preserve control event progress after stale listener readiness - #2319

Merged
fslongjin merged 1 commit into
DragonOS-Community:masterfrom
fslongjin:codex/ngc007-listener-control-progress
Sep 22, 2026
Merged

fslongjin merged 1 commit into
DragonOS-Community:masterfrom
fslongjin:codex/ngc007-listener-control-progress

Conversation

@fslongjin

Copy link
Copy Markdown
Member

Summary

Add two deterministic dunitest regressions ensuring that consumed listener readiness cannot block an event-driven worker from processing its control channel.

The nginx graceful shutdown hang is addressed by the socket-mode synchronization fix already merged in #2317. Removing only the synchronization in File::set_flags reproduces the hang: the master receives SIGQUIT, one worker exits, and another remains blocked in accept4. This PR protects that contract without adding another kernel fix or nginx-specific workaround.

Test design

  • Enable listener nonblocking mode through FIONBIO and duplicate the listener.
  • Observe listener EPOLLIN, then consume the connection through the alias.
  • Queue a byte on a separate nonblocking control socket.
  • Require accept/accept4 to return EAGAIN for the previously reported listener readiness.
  • Return to epoll and verify the control message can be processed.

Reuse existing FD ownership and bounded child-process helpers. No racing threads, sleeps, new dependencies, or application framework are needed. The accept4 flag still controls only the new connection, not whether the listener waits.

Validation

  • Linux: 21/21 socket_nonblocking cases pass.
  • Controlled old-behavior guest: both new cases detect incorrect blocking and are terminated/reaped by the existing watchdog.
  • Current DragonOS: 21 socket_nonblocking, 3 tcp_listen_poll_semantics and 40 tcp_relisten cases pass (64 total).
  • Default nginx: ten start/quit cycles pass, including IPv4/IPv6 requests; recorded master/worker PIDs disappear, the pidfile is removed, and the next startup succeeds.
  • An in-flight proxy request completes with the correct body after QUIT; workers and master then exit normally, without force-kill or an artificial shutdown deadline.
  • make kernel, FMT_CHECK=1 make fmt and git diff --check pass.
  • Independent plan and implementation review found no blocking issues.

Known validation limitation

The three existing tcp_accept_handshake cases fail to observe SYN-ACK in this environment, with synthetic-peer TTL-exceeded diagnostics. Rebuilding the suite and running it first in a fresh snapshot with the unchanged master kernel reproduces all three failures, before nginx or the newly added tests run. That separate baseline/fixture issue is unresolved; this PR does not claim the complete network suite passes and does not alter those tests or routes to hide the failure.

…ness

Add deterministic accept and accept4 regression coverage for readiness consumed through a duplicated listener. Enable listener nonblocking mode with FIONBIO, observe EPOLLIN, accept the sole connection through an alias, and require EAGAIN when using the stale readiness before processing a queued control message.

This protects the event-loop contract implicated in nginx graceful shutdown hangs. The runtime mode synchronization fix is already merged in DragonOS-Community#2317. Reuse the existing socket ownership helper and bounded child watchdog; no kernel changes, threads, sleeps, new dependencies, or nginx-specific behavior are introduced.

Validation: 21 socket_nonblocking cases pass on Linux and DragonOS; the two new cases detect blocking with only the previous FIONBIO mode divergence restored. 64 focused guest cases pass, as do ten default nginx start/quit cycles and graceful completion of an in-flight proxy request. Kernel build, formatting, and independent design/code review pass.

Additional validation limitation: all three existing tcp_accept_handshake cases fail to observe SYN-ACK on the unchanged master kernel, including a fresh guest before nginx or the new tests run. That separate baseline failure remains unresolved and is not counted as passing coverage.

Signed-off-by: longjin <longjin@dragonos.org>
@github-actions github-actions Bot added the test Unitest/User space test label Sep 22, 2026
@fslongjin

Copy link
Copy Markdown
Member Author

@codex review

@fslongjin
fslongjin merged commit 811a9ec into DragonOS-Community:master Sep 22, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Unitest/User space test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant