From aec9af0acba6c997b9bb61e5c3287fae2bb783bf Mon Sep 17 00:00:00 2001 From: Dave Cheney Date: Sat, 22 Sep 2012 05:54:50 +1000 Subject: [PATCH] [release-branch.go1] net/http/httputil: fix race in DumpRequestOut MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ««« backport 3b78b41a4b50 net/http/httputil: fix race in DumpRequestOut Fixes #3892. Swapping the order of the writers inside the MultiWriter ensures the request will be written to buf before http.ReadRequest completes. The fencedBuffer is not required to make the test pass on any machine that I have access too, but as the buf is shared across goroutines, I think it is necessary for correctness. R=bradfitz, fullung, franciscossouza CC=golang-dev https://golang.org/cl/6483061 »»» --- src/pkg/net/http/httputil/dump.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkg/net/http/httputil/dump.go b/src/pkg/net/http/httputil/dump.go index 892ef4eded..0fb2eeb8c0 100644 --- a/src/pkg/net/http/httputil/dump.go +++ b/src/pkg/net/http/httputil/dump.go @@ -89,7 +89,7 @@ func DumpRequestOut(req *http.Request, body bool) ([]byte, error) { t := &http.Transport{ Dial: func(net, addr string) (net.Conn, error) { - return &dumpConn{io.MultiWriter(pw, &buf), dr}, nil + return &dumpConn{io.MultiWriter(&buf, pw), dr}, nil }, } -- 2.50.0