Files
ggbdpq c313a906f4 handoff: Give no longer leaves the handed socket's listener blocking (#4107)
A restart that hands the gateway over reads the copy of its listening
socket (ListenerFile) to send it along (Give). The copy shares the
listener's open file description (TCPListener.File dups the fd), and
os.File.Fd puts such a description in blocking mode: a socket's File
hands out expecting its Fd to be read, and SetBlocking then takes the
O_NONBLOCK flag off the description the copy and the listener share.
The gateway's own listener went blocking with it: its accept slept in
the syscall once nothing came queued, where Close cannot reach it —
the pollDesc evict wakes I/O waiting in the netpoller, not a syscall,
and the listener's own FD still counted as non-blocking, so Close
waited on its condition variable for that accept to return.
stopAccepting waited there, ListenAndServe never returned, and the
ending magpie hung: under a full-suite load TestRestartHandsTheGatewayOver
sat 43 minutes with the handover goroutine in semacquire inside
gateway.(*Server).stopAccepting (the 2701s timeout, #4107). Alone it
passed, as the accept only sleeps there when it comes around with no
connection queued, which a quiet machine rarely gives.

Give now takes the number to send from SyscallConn, which reads it
without the blocking switch.

Red before, green after: TestGiveKeepsTheListenerNonblocking — a
listener handed over with Give keeps its O_NONBLOCK (sub-second,
deterministic; on the old Give it fails "Give left the listener in
blocking mode (os.File.Fd on the copy)").

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 10:22:56 +08:00
..