Skip to content

Fix per-host connection permit leak on the connect path#2288

Merged
hyperxpro merged 3 commits into
mainfrom
fix/2189-connect-permit-leak
Jul 25, 2026
Merged

Fix per-host connection permit leak on the connect path#2288
hyperxpro merged 3 commits into
mainfrom
fix/2189-connect-permit-leak

Conversation

@hyperxpro

@hyperxpro hyperxpro commented Jul 24, 2026

Copy link
Copy Markdown
Member

Motivation:

NettyConnectListener.onSuccess() removes the per-host permit from the future before the TLS handshake completes, preventing abort() from releasing it. Until the handshake succeeds, failures can still occur, leaving the permit without an owner.

Modification:

Transfer permit ownership to channel.closeFuture() as soon as it leaves the future, ensuring it is released exactly once. Also publish the channel before the handshake starts so timeout-triggered aborts can immediately close the socket.

Result:

Permits are preserved across all connect-path exits, and timed-out requests now close their sockets immediately.
Fixes #2189.

@hyperxpro hyperxpro changed the title Bind the connection permit to the channel on connect Fix per-host connection permit leak on the connect path Jul 25, 2026
Comment thread client/src/test/java/org/asynchttpclient/ws/WebSocketUpgradeTimeoutRaceTest.java Dismissed
@hyperxpro
hyperxpro force-pushed the fix/2189-connect-permit-leak branch from e3b36cb to 7f3aebf Compare July 25, 2026 15:49
@hyperxpro
hyperxpro merged commit 64eb57a into main Jul 25, 2026
30 checks passed
@hyperxpro
hyperxpro deleted the fix/2189-connect-permit-leak branch July 25, 2026 16:09
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.

Possible HTTP/1.1 per-host permit leak on request-timeout / connect-success race

1 participant