Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions http2/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -1444,8 +1444,26 @@ func (cs *clientStream) writeRequest(req *http.Request) (err error) {
respHeaderRecv = nil
respHeaderTimer = nil // keep waiting for END_STREAM
case <-cs.abort:
// If this was the only active stream, mark the connection
// as not for re-use in order to address raciness if the caller
// tries to call closeIdleConnections() before the stream has been
// removed
if len(cc.streams) == 1 {
cc.mu.Lock()
cc.doNotReuse = true
cc.mu.Unlock()
}
return cs.abortErr
case <-ctx.Done():
// If this was the only active stream, mark the connection
// as not for re-use in order to address raciness if the caller
// tries to call closeIdleConnections() before the stream has been
// removed
if len(cc.streams) == 1 {
cc.mu.Lock()
cc.doNotReuse = true
cc.mu.Unlock()
}
return ctx.Err()
case <-cs.reqCancel:
return errRequestCanceled
Expand Down