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.
This commit is contained in:
David Fifield 2023-04-04 19:09:47 -06:00
parent 6bae31f077
commit 97c930013b

View file

@ -99,10 +99,11 @@ func TestQueuePacketConnWriteToKCP(t *testing.T) {
defer readyClose.Do(func() { close(ready) }) defer readyClose.Do(func() { close(ready) })
pconn := DiscardPacketConn{} pconn := DiscardPacketConn{}
defer pconn.Close() defer pconn.Close()
loop:
for { for {
select { select {
case <-done: case <-done:
break break loop
default: default:
} }
// Create a new UDPSession, send once, then discard the // Create a new UDPSession, send once, then discard the