summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabrizio Milo <mistobaan@gmail.com>2014-05-12 09:37:36 -0700
committerFabrizio Milo <mistobaan@gmail.com>2014-05-12 09:37:36 -0700
commit53b23f145d7f42981061ec448ce52046c4fd8261 (patch)
treebfd33a33409cb0f950b58d7dd00b6d7cf9b98abc
parentbf9447e07b4ab9e1c1bc12b8ae1e25b91640fb51 (diff)
downloadgo-53b23f145d7f42981061ec448ce52046c4fd8261.tar.gz
net/http: fix flaky test
Prevent idle transport on race condition. Fixes issue 7847 LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://codereview.appspot.com/96230044 Committer: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r--src/pkg/net/http/transport_test.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/pkg/net/http/transport_test.go b/src/pkg/net/http/transport_test.go
index a5aaa6bab..a69e61720 100644
--- a/src/pkg/net/http/transport_test.go
+++ b/src/pkg/net/http/transport_test.go
@@ -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