mirror of https://github.com/golang/go.git
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
This commit is contained in:
parent
fb392867ae
commit
7e8bc474db
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue