]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1] net/http/httputil: fix race in DumpRequestOut
authorDave Cheney <dave@cheney.net>
Fri, 21 Sep 2012 19:54:50 +0000 (05:54 +1000)
committerDave Cheney <dave@cheney.net>
Fri, 21 Sep 2012 19:54:50 +0000 (05:54 +1000)
««« 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

index 892ef4eded0c1cf56818d99201464312d984c452..0fb2eeb8c003f63c549fff4626a26b013c474ba1 100644 (file)
@@ -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
                },
        }