Skip to content

net/http: cherry-pick two upstream HTTP/2 fixes - #188

Merged
bradfitz merged 2 commits into
tailscale.go1.27from
bradfitz/http2
Sep 16, 2026
Merged

bradfitz merged 2 commits into
tailscale.go1.27from
bradfitz/http2

Conversation

@bradfitz

@bradfitz bradfitz commented Sep 16, 2026 •

Copy link
Copy Markdown
Member
  • [tailscale-cherrypick] net/http: don't pin bufio buffers on conns handed off to HTTP/2
  • [tailscale-cherrypick] net/http: don't cancel request contexts on idle unencrypted HTTP/2 conns

Updates #174

…ded off to HTTP/2

HTTP/2 doesn't use net/http's bufio.Reader and Writer. Release the
reader back to the pool before handing off a connection to HTTP/2,
and don't allocate the Writer if we aren't going to use it.

Updates golang#80735
Updates #174

Change-Id: I818a27fb94ecedb6b679942f739d08612aff8241
Reviewed-on: https://go-review.googlesource.com/c/go/+/833344
Reviewed-by: Nicholas Husin <nsh@golang.org>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit a081f7d)
…e unencrypted HTTP/2 conns

CL 831084 introduced a bug. Because conn.serve now returns as soon as
the HTTP/2 serve goroutine parks, the deferred context cancel now
fires while the connection is still being served. The unencrypted
HTTP/2 path was handing that cancelable context to the HTTP/2 server,
canceling every request context on the connection. Pass the connection
context instead, as the TLS ALPN path already does.

This is a cherry-pick of upstream CL 833444 (patchset 2), which is
still pending submission at https://go-review.googlesource.com/c/go/+/833444.

Adapted for this tree: the test passes optFakeNet to
newClientServerTest. Upstream master's test harness defaults to the
synctest fake network and this tree's harness only uses it when asked,
so without that option the test's real listener keeps the synctest
bubble from ever going idle and the test hangs.

Updates golang#81524
Updates #174

Change-Id: Iea19fb46e4a0d111d90b86ca8390a4d50a3bde5a
(cherry picked from commit becae1c545b2961c0fc6ee0dc9b87917aefa3a63)
@bradfitz
bradfitz merged commit d030173 into tailscale.go1.27 Sep 16, 2026
5 checks passed
@bradfitz
bradfitz deleted the bradfitz/http2 branch September 16, 2026 02:28
bradfitz added a commit to tailscale/tailscale that referenced this pull request Sep 16, 2026
For tailscale/go#188

Updates tailscale/corp#29053

Change-Id: I3d42156b3c2ef824b68033031d9be48fe7989176
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant