Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1874)

Issue 6483061: code review 6483061: net/http/httputil: fix race in DumpRequestOut (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 8 months ago by dave
Modified:
11 years, 8 months ago
Reviewers:
CC:
bradfitz, albert.strasheim, fss, golang-dev
Visibility:
Public.

Description

net/http/httputil: fix race in DumpRequestOut Fixes issue 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.

Patch Set 1 #

Patch Set 2 : diff -r c552fb2b6a6c https://code.google.com/p/go #

Patch Set 3 : diff -r c552fb2b6a6c https://code.google.com/p/go #

Patch Set 4 : diff -r c552fb2b6a6c https://code.google.com/p/go #

Patch Set 5 : diff -r c552fb2b6a6c https://code.google.com/p/go #

Total comments: 4

Patch Set 6 : diff -r c552fb2b6a6c https://code.google.com/p/go #

Patch Set 7 : diff -r c552fb2b6a6c https://code.google.com/p/go #

Total comments: 1

Patch Set 8 : diff -r c552fb2b6a6c https://code.google.com/p/go #

Patch Set 9 : diff -r 288d68924d65 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1 line, -1 line) Patch
M src/pkg/net/http/httputil/dump.go View 1 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 14
dave_cheney.net
Hello bradfitz@golang.org, fullung@gmail.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go
11 years, 8 months ago (2012-08-28 07:08:23 UTC) #1
fss
http://codereview.appspot.com/6483061/diff/10001/src/pkg/net/http/httputil/dump.go File src/pkg/net/http/httputil/dump.go (right): http://codereview.appspot.com/6483061/diff/10001/src/pkg/net/http/httputil/dump.go#newcode116 src/pkg/net/http/httputil/dump.go:116: return fb.Buffer.Write(b) Why not just `fb.Lock`, `fb.Unlock` and `fb.Write`? ...
11 years, 8 months ago (2012-08-28 11:01:48 UTC) #2
dave_cheney.net
http://codereview.appspot.com/6483061/diff/10001/src/pkg/net/http/httputil/dump.go File src/pkg/net/http/httputil/dump.go (right): http://codereview.appspot.com/6483061/diff/10001/src/pkg/net/http/httputil/dump.go#newcode116 src/pkg/net/http/httputil/dump.go:116: return fb.Buffer.Write(b) On 2012/08/28 11:01:48, fss wrote: > Why ...
11 years, 8 months ago (2012-08-28 11:06:03 UTC) #3
fss
On 2012/08/28 11:06:03, dfc wrote: > http://codereview.appspot.com/6483061/diff/10001/src/pkg/net/http/httputil/dump.go > File src/pkg/net/http/httputil/dump.go (right): > > http://codereview.appspot.com/6483061/diff/10001/src/pkg/net/http/httputil/dump.go#newcode116 > ...
11 years, 8 months ago (2012-08-28 13:09:01 UTC) #4
dave_cheney.net
> I see, my suggestion is about the syntax only: you could drop Buffer and ...
11 years, 8 months ago (2012-08-28 13:18:09 UTC) #5
fss
On 2012/08/28 13:18:09, dfc wrote: > [cut] > But then fb.Write would forward to fb.Buffer.Write ...
11 years, 8 months ago (2012-08-28 13:24:33 UTC) #6
dave_cheney.net
> func (fb *fencedBuffer) Write(b []byte) (int, error) { > fb.Lock() > defer fb.Unlock() > ...
11 years, 8 months ago (2012-08-28 13:26:25 UTC) #7
fss
On 2012/08/28 13:26:25, dfc wrote: > > func (fb *fencedBuffer) Write(b []byte) (int, error) { ...
11 years, 8 months ago (2012-08-28 13:29:11 UTC) #8
dave_cheney.net
Hello bradfitz@golang.org, fullung@gmail.com, franciscossouza@gmail.com (cc: golang-dev@googlegroups.com), Please take another look.
11 years, 8 months ago (2012-08-28 13:30:23 UTC) #9
bradfitz
LGTM but I'd rather drop the syncBuffer wrapper if it's not required. It's more code ...
11 years, 8 months ago (2012-08-28 14:07:36 UTC) #10
dave_cheney.net
SGTM. I'll revert the syncBuffer change until it proves necessary. On 29/08/2012, at 0:07, bradfitz@golang.org ...
11 years, 8 months ago (2012-08-28 14:10:24 UTC) #11
dave_cheney.net
Hello bradfitz@golang.org, fullung@gmail.com, franciscossouza@gmail.com (cc: golang-dev@googlegroups.com), Please take another look.
11 years, 8 months ago (2012-08-28 22:54:58 UTC) #12
bradfitz
LGTM On Tue, Aug 28, 2012 at 3:54 PM, <dave@cheney.net> wrote: > Hello bradfitz@golang.org, fullung@gmail.com, ...
11 years, 8 months ago (2012-08-28 22:59:27 UTC) #13
dave_cheney.net
11 years, 8 months ago (2012-08-28 23:06:16 UTC) #14
*** Submitted as http://code.google.com/p/go/source/detail?r=3b78b41a4b50 ***

net/http/httputil: fix race in DumpRequestOut

Fixes issue 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
http://codereview.appspot.com/6483061
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b