Setting a deadline on a Pipe starts a goroutine that wakes blocked
readers or writers when it passes, and only a later SetDeadline or Close
cancels it. But Close only cancels the timers it finds, so setting a
deadline after Close started a goroutine nothing would ever cancel,
which lived until the deadline passed.
An http.Server does exactly that if it's closed between accepting a
conn and serving it: conn.serve sets the TLS handshake deadlines on the
already-closed conn, then fails the handshake. Under synctest, the
leftover goroutines make the test fail with "main bubble goroutine has
exited but blocked goroutines remain", as seen in a lansport test in
tailscale/tb on Windows CI.
A closed Pipe has no blocked readers or writers left to wake, so don't
arm a timer for it. The deadline itself is still recorded.
Updates tailscale/corp#51705
Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: I772ca698fc81f7389542e87d108eec0c04b98df1