diff options
author | Brad Fitzpatrick <bradfitz@golang.org> | 2016-07-22 21:58:18 +0000 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-07-22 22:23:14 +0000 |
commit | 10538a8f9e2e718a47633ac5a6e90415a2c3f5f1 (patch) | |
tree | c51d052bd9e9019f629f9881454f9c6be4f54ef1 | |
parent | 243d51f05e5dc263e185f9b1f7f1fe96a2098644 (diff) | |
download | go-10538a8f9e2e718a47633ac5a6e90415a2c3f5f1.tar.gz go-10538a8f9e2e718a47633ac5a6e90415a2c3f5f1.zip |
net/http: fix potential for-select spin with closed Context.Done channel
Noticed when investigating a separate issue.
No external bug report or repro yet.
Change-Id: I8a1641a43163f22b09accd3beb25dd9e2a68a238
Reviewed-on: https://go-review.googlesource.com/25152
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
-rw-r--r-- | src/net/http/transport.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/net/http/transport.go b/src/net/http/transport.go index 9164d0d827..a51f1d0658 100644 --- a/src/net/http/transport.go +++ b/src/net/http/transport.go @@ -1784,6 +1784,7 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err var re responseAndError var respHeaderTimer <-chan time.Time cancelChan := req.Request.Cancel + ctxDoneChan := req.Context().Done() WaitResponse: for { testHookWaitResLoop() @@ -1815,9 +1816,11 @@ WaitResponse: case <-cancelChan: pc.t.CancelRequest(req.Request) cancelChan = nil - case <-req.Context().Done(): + ctxDoneChan = nil + case <-ctxDoneChan: pc.t.CancelRequest(req.Request) cancelChan = nil + ctxDoneChan = nil } } |