Commit da87cf5d authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/http: fix a data race when Request.Cancel is used

The "add a Request.Cancel channel" change (https://golang.org/cl/11601)
added support for "race free" cancellation, but introduced a data race. :)

Noticed while running "go test -race net/http". The test is skipped in
short mode, so we never saw it on the dashboard.

Change-Id: Ica14579d8723f8f9d1691e8d56c30b585b332c64
Reviewed-on: https://go-review.googlesource.com/12663Reviewed-by: default avatarAaron Jacobs <jacobsa@google.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 56a06240
......@@ -975,6 +975,7 @@ func (pc *persistConn) readLoop() {
// the underlying bufio reader.
select {
case <-rc.req.Cancel:
alive = false
pc.t.CancelRequest(rc.req)
case bodyEOF := <-waitForBodyRead:
pc.t.setReqCanceler(rc.req, nil) // before pc might return to idle pool
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment