Files
tailscale/derp/derpserver
Mike O'Driscoll 28f22b0062 derp/derpserver: make writer flood test deterministic (#22629)
TestWriterFloodDoesNotStarveControlFrames raced a flooding goroutine
against a writer goroutine and polled with wall-clock timeouts. Its
original sequence-number bound was wrong under CPU load and was fixed
in #22553, which is what the failures reported in #22614 were
hitting. But the test still depended on scheduling, and so only
sometimes caught a regression: with writePending's per-pass budget
doubled it failed about half its runs.

Make it single-threaded instead. The test runs the writer inline, as
onKeepAliveTimer does, and sends packets as big as the writer's
buffer, so that every packet reaches the fake conn's Write. Write tops
the send queue back up and queues the pong once the writer has sent an
exact number of packets. The pong is queued at each of depth+1
consecutive packet counts, so that a per-pass budget of more than
depth is caught at its worst case whatever it is, and the flood is
bounded so that a writer that starves the pong fails the test rather
than hanging it.

Fixes #22614

Signed-off-by: Mike O'Driscoll <[email protected]>
2026-11-25 11:00:30 -05:00
..