Skip to content

Commit e204ce3

Browse files
author
Bryan C. Mills
committed
netutil: in TestLimitListenerSaturation, allow some connections to fail to dial
When the listener saturates, the kernel will typically buffer the remaining pending connections (so they will eventually succeed in dialing). However, that behavior is not guaranteed, and it empirically doesn't always hold: a failure was observed in https://build.golang.org/log/5ac7312814bcff4841563be043f28aaefa9b3c90. We do expect to be able to dial at least as many connections as the listener will accept, and we expect every connection that is accepted to be served to completion. Updates golang/go#22926 Change-Id: I4cb39c8f39fda0dcb905f548612ccdf1856f2a66 Reviewed-on: https://go-review.googlesource.com/c/net/+/380155 Trust: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 2ed6ce1 commit e204ce3

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

netutil/listen_test.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,17 @@ func TestLimitListenerSaturation(t *testing.T) {
203203
wg.Wait()
204204

205205
t.Logf("served %d connections (of %d dialed, %d attempted)", served, dialed, attemptsPerWave)
206-
// We expect that the kernel can queue at least attemptsPerWave
207-
// connections at a time (since it's only a small number), so every
208-
// connection should eventually be served.
209-
if served != attemptsPerWave {
210-
t.Errorf("expected %d served", attemptsPerWave)
206+
207+
// Depending on the kernel's queueing behavior, we could get unlucky
208+
// and drop one or more connections. However, we should certainly
209+
// be able to serve at least max attempts out of each wave.
210+
// (In the typical case, the kernel will queue all of the connections
211+
// and they will all be served successfully.)
212+
if dialed < max {
213+
t.Errorf("expected at least %d dialed", max)
214+
}
215+
if served < dialed {
216+
t.Errorf("expected all dialed connections to be served")
211217
}
212218
}
213219
}

0 commit comments

Comments
 (0)