]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: deflake TestServerSetKeepAlivesEnabledClosesConns
authorBrad Fitzpatrick <bradfitz@golang.org>
Thu, 3 Nov 2016 01:11:49 +0000 (01:11 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 3 Nov 2016 03:20:01 +0000 (03:20 +0000)
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>
src/net/http/export_test.go
src/net/http/serve_test.go

index fbed45070c880e6abb543f59216a62b28340e7e3..40f87dc8e94cfae775b767372b8dd0c6c7cb5fbc 100644 (file)
@@ -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
+}
index f855c358221dadcb2962d9bc6a28ab156a562cbf..fe63c6925f7294ecc5bab755844032d3e1c8b712 100644 (file)
@@ -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)