Skip to content

client: admit only real session creation - #1

Closed
Piggy-Cat-bit-shadow wants to merge 1 commit into
SagerNet:mainfrom
Piggy-Cat-bit-shadow:fix/admit-creation-only-2026-11-12
Closed

Piggy-Cat-bit-shadow wants to merge 1 commit into
SagerNet:mainfrom
Piggy-Cat-bit-shadow:fix/admit-creation-only-2026-11-12

Conversation

@Piggy-Cat-bit-shadow

Copy link
Copy Markdown

DialContext first tries to reuse an idle session and only then creates one. The two paths have different costs: a reuse opens one stream, while a creation pays a TCP connect, a TLS handshake and the first write. A caller that bounds session creation had to wrap DialContext, so a healthy reuse waited behind creations it was not part of.

DialContext first tries to reuse an idle session and only then creates one. These two paths have different costs: a reuse opens one stream, a creation pays a TCP connect, a TLS handshake and the first write. A caller that bounds creation had to wrap DialContext, so a healthy reuse waited behind creations it was not part of.

Add ClientOptions.AdmitCreation. It is called exactly once per new session, after the reuse attempt failed, and owns the call: it must invoke create exactly once and return its error, so a refusal means no dial happens and the actual creation error is what the caller's outcome accounting sees. A nil hook keeps the previous behaviour.
@Piggy-Cat-bit-shadow
Piggy-Cat-bit-shadow deleted the fix/admit-creation-only-2026-11-12 branch November 12, 2026 16:28
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