]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: regenerate h2_bundle.go
authorBryan C. Mills <bcmills@google.com>
Tue, 9 May 2023 13:00:02 +0000 (09:00 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 9 May 2023 13:22:59 +0000 (13:22 +0000)
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>
src/net/http/h2_bundle.go

index 8ec90cdabb5e81b635cf82ee973e2431fbbf86e2..ed8d53ab3b98fad9ff268b86b9a45491a49204fd 100644 (file)
@@ -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)
                }
        }
 }