Skip to content

Commit e4e1ae7

Browse files
committed
http2: revert more of upstream http2 change
Even the part we previously kept was bad. Revert all of 82780d6 but keep 6826f5a (which depended on bits of 82780d6). So this is a mix. TestTransportRetryAfterRefusedStream fails with this change, but only because it was adjusted in 82780d6 to pass with 82780d6, and this test doesn't revert all the test changes. I just skip that test instead, because it doesn't really affect us. Updates tailscale/corp#12296 Updates golang/go#60818 Signed-off-by: Brad Fitzpatrick <brad@danga.com>
1 parent 2b899ee commit e4e1ae7

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

http2/transport.go

+7-24
Original file line numberDiff line numberDiff line change
@@ -1266,29 +1266,9 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) {
12661266
return res, nil
12671267
}
12681268

1269-
cancelRequest := func(cs *clientStream, markDoNotReuse bool, err error) error {
1269+
cancelRequest := func(cs *clientStream, err error) error {
12701270
cs.cc.mu.Lock()
1271-
cs.abortStreamLocked(err)
12721271
bodyClosed := cs.reqBodyClosed
1273-
if markDoNotReuse && cs.ID != 0 {
1274-
// This request may have failed because of a problem with the connection,
1275-
// or for some unrelated reason. (For example, the user might have canceled
1276-
// the request without waiting for a response.) Mark the connection as
1277-
// not reusable, since trying to reuse a dead connection is worse than
1278-
// unnecessarily creating a new one.
1279-
//
1280-
// If cs.ID is 0, then the request was never allocated a stream ID and
1281-
// whatever went wrong was unrelated to the connection. We might have
1282-
// timed out waiting for a stream slot when StrictMaxConcurrentStreams
1283-
// is set, for example, in which case retrying on a different connection
1284-
// will not help.
1285-
cs.cc.doNotReuse = true
1286-
1287-
if f := cs.cc.t.CountError; f != nil {
1288-
f("abort_set_do_not_reuse")
1289-
log.Printf("ts-http2: set do not reuse: %T, %v", err, err)
1290-
}
1291-
}
12921272
cs.cc.mu.Unlock()
12931273
// Wait for the request body to be closed.
12941274
//
@@ -1323,12 +1303,15 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) {
13231303
return handleResponseHeaders()
13241304
default:
13251305
waitDone()
1326-
return nil, cancelRequest(cs, true, cs.abortErr)
1306+
return nil, cs.abortErr
13271307
}
13281308
case <-ctx.Done():
1329-
return nil, cancelRequest(cs, false, ctx.Err())
1309+
err := ctx.Err()
1310+
cs.abortStream(err)
1311+
return nil, cancelRequest(cs, err)
13301312
case <-cs.reqCancel:
1331-
return nil, cancelRequest(cs, false, errRequestCanceled)
1313+
cs.abortStream(errRequestCanceled)
1314+
return nil, cancelRequest(cs, errRequestCanceled)
13321315
}
13331316
}
13341317
}

http2/transport_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -3857,6 +3857,7 @@ func TestTransportRetryAfterGOAWAY(t *testing.T) {
38573857
}
38583858

38593859
func TestTransportRetryAfterRefusedStream(t *testing.T) {
3860+
t.Skip("broken by 82780d60 and later reverts; see https://github.com/golang/go/issues/60818 and https://github.com/tailscale/corp/issues/12296")
38603861
clientDone := make(chan struct{})
38613862
client := func(tr *Transport) {
38623863
defer close(clientDone)

0 commit comments

Comments
 (0)