Commit 7e8bc474 authored by Fabrizio Milo's avatar Fabrizio Milo Committed by Brad Fitzpatrick

net/http: fix flaky test

Prevent idle transport on race condition.

Fixes #7847

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/96230044
parent fb392867
......@@ -1553,8 +1553,10 @@ func TestTransportSocketLateBinding(t *testing.T) {
dialGate := make(chan bool, 1)
tr := &Transport{
Dial: func(n, addr string) (net.Conn, error) {
<-dialGate
return net.Dial(n, addr)
if <-dialGate {
return net.Dial(n, addr)
}
return nil, errors.New("manually closed")
},
DisableKeepAlives: false,
}
......@@ -1589,7 +1591,7 @@ func TestTransportSocketLateBinding(t *testing.T) {
t.Fatalf("/foo came from conn %q; /bar came from %q instead", fooAddr, barAddr)
}
barRes.Body.Close()
dialGate <- true
dialGate <- false
}
// Issue 2184
......
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