]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: fix race on postPendingDial test hook
authorTodd Neal <todd@tneal.org>
Thu, 18 Jun 2015 12:26:39 +0000 (07:26 -0500)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sun, 28 Jun 2015 16:14:07 +0000 (16:14 +0000)
The race occurs rarely, but by putting some delays and more reads/writes
of prePendingDial/postPendingDial in the handlePendingDial function I
could reproduce it.

Fixes #11136

Change-Id: I8da9e66c88fbda049eaaaaffa2717264ef327768
Reviewed-on: https://go-review.googlesource.com/11250
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

src/net/http/transport.go

index 70797ddfe7e7ea8cc42c4f2312583f579d287b44..e4854e8a146402d9ddaa120a9b990793e461f184 100644 (file)
@@ -523,6 +523,11 @@ func (t *Transport) getConn(req *Request, cm connectMethod) (*persistConn, error
        }
        dialc := make(chan dialRes)
 
+       // Copy these hooks so we don't race on the postPendingDial in
+       // the goroutine we launch. Issue 11136.
+       prePendingDial := prePendingDial
+       postPendingDial := postPendingDial
+
        handlePendingDial := func() {
                if prePendingDial != nil {
                        prePendingDial()