mirror of
https://github.com/golang/go
synced 2024-11-23 16:00:06 -07:00
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>
This commit is contained in:
parent
243d51f05e
commit
10538a8f9e
@ -1784,6 +1784,7 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err
|
|||||||
var re responseAndError
|
var re responseAndError
|
||||||
var respHeaderTimer <-chan time.Time
|
var respHeaderTimer <-chan time.Time
|
||||||
cancelChan := req.Request.Cancel
|
cancelChan := req.Request.Cancel
|
||||||
|
ctxDoneChan := req.Context().Done()
|
||||||
WaitResponse:
|
WaitResponse:
|
||||||
for {
|
for {
|
||||||
testHookWaitResLoop()
|
testHookWaitResLoop()
|
||||||
@ -1815,9 +1816,11 @@ WaitResponse:
|
|||||||
case <-cancelChan:
|
case <-cancelChan:
|
||||||
pc.t.CancelRequest(req.Request)
|
pc.t.CancelRequest(req.Request)
|
||||||
cancelChan = nil
|
cancelChan = nil
|
||||||
case <-req.Context().Done():
|
ctxDoneChan = nil
|
||||||
|
case <-ctxDoneChan:
|
||||||
pc.t.CancelRequest(req.Request)
|
pc.t.CancelRequest(req.Request)
|
||||||
cancelChan = nil
|
cancelChan = nil
|
||||||
|
ctxDoneChan = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user