Commit be7c50a7 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/http: deflake TestServerSetKeepAlivesEnabledClosesConns

Fixes #17754
Updates #9478 (details in here)

Change-Id: Iae2c1ca05a18ed266b53b2594c22fc57fab33c5e
Reviewed-on: https://go-review.googlesource.com/32587
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 66504485
......@@ -186,3 +186,15 @@ func ExportHttp2ConfigureTransport(t *Transport) error {
}
var Export_shouldCopyHeaderOnRedirect = shouldCopyHeaderOnRedirect
func (s *Server) ExportAllConnsIdle() bool {
s.mu.Lock()
defer s.mu.Unlock()
for c := range s.activeConn {
st, ok := c.curState.Load().(ConnState)
if !ok || st != StateIdle {
return false
}
}
return true
}
......@@ -4875,6 +4875,9 @@ func TestServerSetKeepAlivesEnabledClosesConns(t *testing.T) {
}) {
t.Fatalf("idle count before SetKeepAlivesEnabled called = %v; want 1", idle0)
}
if !waitCondition(2*time.Second, 10*time.Millisecond, ts.Config.ExportAllConnsIdle) {
t.Fatalf("test server has active conns")
}
ts.Config.SetKeepAlivesEnabled(false)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment