aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/client_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/http/client_test.go')
-rw-r--r--src/net/http/client_test.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/net/http/client_test.go b/src/net/http/client_test.go
index dc499a90b6..b1d8799fa5 100644
--- a/src/net/http/client_test.go
+++ b/src/net/http/client_test.go
@@ -927,7 +927,14 @@ func TestClientTimeout_Headers(t *testing.T) {
<-donec
}))
defer ts.Close()
- defer close(donec)
+ // Note that we use a channel send here and not a close.
+ // The race detector doesn't know that we're waiting for a timeout
+ // and thinks that the waitgroup inside httptest.Server is added to concurrently
+ // with us closing it. If we timed out immediately, we could close the testserver
+ // before we entered the handler. We're not timing out immediately and there's
+ // no way we would be done before we entered the handler, but the race detector
+ // doesn't know this, so synchronize explicitly.
+ defer func() { donec <- true }()
c := &Client{Timeout: 500 * time.Millisecond}