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

@hyperxprohyperxpro 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.

@hyperxprohyperxpro changed the title Bind the connection permit to the channel on connectFix per-host connection permit leak on the connect pathJul 25, 2026
@hyperxpro
hyperxproforce-pushed the fix/2189-connect-permit-leak branch from e3b36cb to 7f3aebfCompareJuly 25, 2026 15:49
@hyperxpro
hyperxpro merged commit 64eb57a into mainJul 25, 2026
30 checks passed
@hyperxpro
hyperxpro deleted the fix/2189-connect-permit-leak branch July 25, 2026 16:09
hyperxpro added a commit that referenced this pull request Aug 2, 2026
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 added a commit that referenced this pull request Aug 2, 2026
… io_uring fallback
Fixes for PR #2216 CI failures on io_uring:
- InputStreamMultipartPart: prevent infinite loop with slowTarget backpressure
- StackTraceInspector: detect native transport connection resets via errno matching
- NettyChannelConnector: annotate connect failures with host:port for io_uring
- ChannelManager: fallback from io_uring to epoll on ring allocation failure
(io_uring rings charge against RLIMIT_MEMLOCK, not always available)
Rebased on #2288 (Fix per-host connection permit leak) for proper semaphore handling.
hyperxpro added a commit that referenced this pull request Aug 2, 2026
… io_uring fallback
Fixes for PR #2216 CI failures on io_uring:
- InputStreamMultipartPart: prevent infinite loop with slowTarget backpressure
- StackTraceInspector: detect native transport connection resets via errno matching
- NettyChannelConnector: annotate connect failures with host:port for io_uring
- ChannelManager: fallback from io_uring to epoll on ring allocation failure
(io_uring rings charge against RLIMIT_MEMLOCK, not always available)
Rebased on #2288 (Fix per-host connection permit leak) for proper semaphore handling.
hyperxpro added a commit that referenced this pull request Aug 2, 2026
… io_uring fallback
Fixes for PR #2216 CI failures on io_uring:
- InputStreamMultipartPart: prevent infinite loop with slowTarget backpressure
- StackTraceInspector: detect native transport connection resets via errno matching
- NettyChannelConnector: annotate connect failures with host:port for io_uring
- ChannelManager: fallback from io_uring to epoll on ring allocation failure
(io_uring rings charge against RLIMIT_MEMLOCK, not always available)
Rebased on #2288 (Fix per-host connection permit leak) for proper semaphore handling.
hyperxpro added a commit that referenced this pull request Aug 2, 2026
… io_uring fallback
Fixes for PR #2216 CI failures on io_uring:
- InputStreamMultipartPart: prevent infinite loop with slowTarget backpressure
- StackTraceInspector: detect native transport connection resets via errno matching
- NettyChannelConnector: annotate connect failures with host:port for io_uring
- ChannelManager: fallback from io_uring to epoll on ring allocation failure
(io_uring rings charge against RLIMIT_MEMLOCK, not always available)
Rebased on #2288 (Fix per-host connection permit leak) for proper semaphore handling.
Sign up for freeto 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

@hyperxpro