Skip to content

Commit

Permalink
net/http: deflake TestServerSetKeepAlivesEnabledClosesConns
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bradfitz committed Nov 3, 2016
1 parent 6650448 commit be7c50a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/net/http/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 3 additions & 0 deletions src/net/http/serve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit be7c50a

Please sign in to comment.