Skip to content

Harden the HTTP/2 connection-waiter registry against waiter failures and shutdown races#2251

Merged
hyperxpro merged 1 commit into
mainfrom
h2-waiter-hardening
Jul 18, 2026
Merged

Harden the HTTP/2 connection-waiter registry against waiter failures and shutdown races#2251
hyperxpro merged 1 commit into
mainfrom
h2-waiter-hardening

Conversation

@hyperxpro

@hyperxpro hyperxpro commented Jul 18, 2026

Copy link
Copy Markdown
Member

Motivation:

#2227 introduced an event-driven HTTP/2 connection-waiter registry in ChannelManager, but three issues remained. A waiter throwing an exception could prevent subsequent waiters from being notified and interrupt the connection establishment path, leaking a permit and leaving the request hanging. Requests registering during shutdown could miss both the close notification and timeout, leaving their futures incomplete. Additionally, timed-out or removed waiters left empty per-host sets behind for the lifetime of the client.

Modification:

Isolate waiter callbacks in a notifyHttp2ConnectionWaiter try/catch helper. Add a waitersClosed flag that is latched before the shutdown sweep so new waiters are rejected during shutdown, allowing arm() to fail the request immediately without interacting with the timer. Remove empty waiter sets using computeIfPresent. Added four unit tests covering these scenarios.

Result:

Misbehaving waiters can no longer disrupt connection establishment or leak permits, waiters registered during shutdown fail deterministically instead of hanging, and the registry no longer retains empty per-host entries.

@hyperxpro
hyperxpro merged commit 95f5b21 into main Jul 18, 2026
29 of 30 checks passed
@hyperxpro
hyperxpro deleted the h2-waiter-hardening branch July 18, 2026 20:15
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