From: Todd Neal Date: Thu, 18 Jun 2015 12:26:39 +0000 (-0500) Subject: net/http: fix race on postPendingDial test hook X-Git-Tag: go1.5beta1~77 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7511806ec2914f9d9b6a8941d420fb0443f5f5f6;p=gostls13.git net/http: fix race on postPendingDial test hook 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 Run-TryBot: Brad Fitzpatrick --- diff --git a/src/net/http/transport.go b/src/net/http/transport.go index 70797ddfe7..e4854e8a14 100644 --- a/src/net/http/transport.go +++ b/src/net/http/transport.go @@ -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()