mirror of
https://github.com/golang/go
synced 2024-11-20 10:34:42 -07:00
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: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
66504485eb
commit
be7c50a710
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user