From: Dave Cheney Date: Tue, 28 Aug 2012 23:05:30 +0000 (+1000) Subject: net/http/httputil: fix race in DumpRequestOut X-Git-Tag: go1.1rc2~2576 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f8d4bb884fdb7dc98ee9fb12a9847cb1f322ecbc;p=gostls13.git 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 --- diff --git a/src/pkg/net/http/httputil/dump.go b/src/pkg/net/http/httputil/dump.go index 5a95eb8cc2..0b00356616 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 }, }