From 97c930013b2e5fa4cf81af636e94b38ad0632033 Mon Sep 17 00:00:00 2001 From: David Fifield Date: Tue, 4 Apr 2023 19:09:47 -0600 Subject: [PATCH] Fix loop termination in TestQueuePacketConnWriteToKCP. The noise-generating goroutine was meant to stop when the parent function returned and closed the `done` channel. The `break` in the loop was wrongly exiting only from the `select`, not from the `for`. This was the cause of banchmark anomalies in https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40260#note_2885832. The noise-generating loop from the test was continuing to run while the benchmarks were running. --- common/turbotunnel/queuepacketconn_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/turbotunnel/queuepacketconn_test.go b/common/turbotunnel/queuepacketconn_test.go index 2bb4eeb..37f46bc 100644 --- a/common/turbotunnel/queuepacketconn_test.go +++ b/common/turbotunnel/queuepacketconn_test.go @@ -99,10 +99,11 @@ func TestQueuePacketConnWriteToKCP(t *testing.T) { defer readyClose.Do(func() { close(ready) }) pconn := DiscardPacketConn{} defer pconn.Close() + loop: for { select { case <-done: - break + break loop default: } // Create a new UDPSession, send once, then discard the