aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2023-05-09 09:00:02 -0400
committerGopher Robot <gobot@golang.org>2023-05-09 13:22:59 +0000
commitd8ab19b2f2d754e374af7fc643dac5224667310b (patch)
tree5f60f351ca5205a07315c5f000094164a5fc0138
parent59d19ba797d9bf9544f31a1f9f80e8532b244db5 (diff)
downloadgo-d8ab19b2f2d754e374af7fc643dac5224667310b.tar.xz
net/http: regenerate h2_bundle.go
The x/net version was updated in CL 493596; cmd/internal/moddeps catches the skew, but only runs on the -longtest builders (because it requires network access for the bundle tool and x/net dependency). Change-Id: I48891d51aab23b2ca6f4484215438c60bd8c8c21 Reviewed-on: https://go-review.googlesource.com/c/go/+/493875 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
-rw-r--r--src/net/http/h2_bundle.go30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go
index 8ec90cdabb..ed8d53ab3b 100644
--- a/src/net/http/h2_bundle.go
+++ b/src/net/http/h2_bundle.go
@@ -8287,6 +8287,27 @@ func (cc *http2ClientConn) RoundTrip(req *Request) (*Response, error) {
return res, nil
}
+ cancelRequest := func(cs *http2clientStream, err error) error {
+ cs.cc.mu.Lock()
+ defer cs.cc.mu.Unlock()
+ cs.abortStreamLocked(err)
+ if cs.ID != 0 {
+ // This request may have failed because of a problem with the connection,
+ // or for some unrelated reason. (For example, the user might have canceled
+ // the request without waiting for a response.) Mark the connection as
+ // not reusable, since trying to reuse a dead connection is worse than
+ // unnecessarily creating a new one.
+ //
+ // If cs.ID is 0, then the request was never allocated a stream ID and
+ // whatever went wrong was unrelated to the connection. We might have
+ // timed out waiting for a stream slot when StrictMaxConcurrentStreams
+ // is set, for example, in which case retrying on a different connection
+ // will not help.
+ cs.cc.doNotReuse = true
+ }
+ return err
+ }
+
for {
select {
case <-cs.respHeaderRecv:
@@ -8301,15 +8322,12 @@ func (cc *http2ClientConn) RoundTrip(req *Request) (*Response, error) {
return handleResponseHeaders()
default:
waitDone()
- return nil, cs.abortErr
+ return nil, cancelRequest(cs, cs.abortErr)
}
case <-ctx.Done():
- err := ctx.Err()
- cs.abortStream(err)
- return nil, err
+ return nil, cancelRequest(cs, ctx.Err())
case <-cs.reqCancel:
- cs.abortStream(http2errRequestCanceled)
- return nil, http2errRequestCanceled
+ return nil, cancelRequest(cs, http2errRequestCanceled)
}
}
}