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

Issue 51700043: code review 51700043: net/http: fix another data race when sharing Request.Body (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 4 months ago by bradfitz
Modified:
10 years, 4 months ago
Reviewers:
khr
CC:
golang-codereviews, khr
Visibility:
Public.

Description

net/http: fix another data race when sharing Request.Body Fix another issue (similar to Issue 6995) where there was a data race when sharing a server handler's Request.Body with another goroutine that out-lived the Handler's goroutine. In some cases we were not closing the incoming Request.Body (which would've required reading it until the end) if we thought it we thought we were going to be forcibly closing the underlying net.Conn later anyway. But that optimization largely moved to the transfer.go *body later, and locking was added to *body which then detected read-after-close, so now calling the (*body).Close always is both cheap and correct. No new test because TestTransportAndServerSharedBodyRace caught it, albeit only sometimes. Running: while ./http.test -test.cpu=8 -test.run=TestTransportAndServerSharedBodyRace; do true; done ... would reliably cause a race before, but not now. Update Issue 6995 Fixes Issue 7092

Patch Set 1 #

Patch Set 2 : code review 51700043: net/http: fix another data race when sharing Request.Body #

Patch Set 3 : diff -r 0337092aa784 https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r c0e0467635ec https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+4 lines, -5 lines) Patch
M src/pkg/net/http/server.go View 1 2 1 chunk +4 lines, -5 lines 0 comments Download

Messages

Total messages: 3
bradfitz
Hello golang-codereviews@googlegroups.com, I'd like you to review this change to https://go.googlecode.com/hg/
10 years, 4 months ago (2014-01-13 23:12:56 UTC) #1
khr
On 2014/01/13 23:12:56, bradfitz wrote: > Hello mailto:golang-codereviews@googlegroups.com, > > I'd like you to review ...
10 years, 4 months ago (2014-01-14 04:30:26 UTC) #2
bradfitz
10 years, 4 months ago (2014-01-14 17:46:43 UTC) #3
*** Submitted as https://code.google.com/p/go/source/detail?r=51a204237ba5 ***

net/http: fix another data race when sharing Request.Body

Fix another issue (similar to Issue 6995) where there was a
data race when sharing a server handler's Request.Body with
another goroutine that out-lived the Handler's goroutine.

In some cases we were not closing the incoming Request.Body
(which would've required reading it until the end) if we
thought it we thought we were going to be forcibly closing the
underlying net.Conn later anyway. But that optimization
largely moved to the transfer.go *body later, and locking was
added to *body which then detected read-after-close, so now
calling the (*body).Close always is both cheap and correct.

No new test because TestTransportAndServerSharedBodyRace caught it,
albeit only sometimes. Running:

while ./http.test -test.cpu=8 -test.run=TestTransportAndServerSharedBodyRace; do
true; done

... would reliably cause a race before, but not now.

Update Issue 6995
Fixes Issue 7092

R=golang-codereviews, khr
CC=golang-codereviews
https://codereview.appspot.com/51700043
Sign in to reply to this message.

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