Skip to content

Fix double return of the TLS handshake's timeout source in TcpServer - #307

Merged
sakno merged 1 commit into
dotnet:developfrom
ferociousbyte:fix/tcpserver-timeout-scope
Oct 26, 2026
Merged

sakno merged 1 commit into
dotnet:developfrom
ferociousbyte:fix/tcpserver-timeout-scope

Conversation

@ferociousbyte

@ferociousbyte ferociousbyte commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #306. After the TLS handshake the timeout scope is reset, so the connection's finally no longer returns the same pooled CancellationTokenSource a second time (which threw ObjectDisposedException from async void HandleConnection on shutdown and could share one source between two connections).

Includes a regression test.

This change was made with the help of an AI model (Claude). I can't set labels on this repository; could a maintainer please add ai_assisted?

After the TLS handshake the timeout scope was returned to the multiplexer's
pool but not reset, so a connection that ended before its first message
returned it again in HandleConnection's finally. If the pooled source had
been disposed meanwhile (e.g. canceled by another connection's handshake
timeout, or on shutdown), TryReset threw ObjectDisposedException from the
async void method and the process terminated; otherwise the same source
could be handed to two connections.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ferociousbyte

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree

@ferociousbyte
ferociousbyte marked this pull request as draft October 24, 2026 09:05
@ferociousbyte
ferociousbyte marked this pull request as ready for review October 24, 2026 09:05
@sakno

sakno commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

@ferociousbyte , thanks for your contribution!

@sakno sakno added the Lib:Cluster DotNext.Net.Cluster library label Oct 26, 2026
@sakno
sakno merged commit b0e7a55 into dotnet:develop Oct 26, 2026
3 of 5 checks passed
@sakno sakno added the ai_assisted Bug or PR is produced partially or fully by the AI model (Codex, Claude, etc.) label Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai_assisted Bug or PR is produced partially or fully by the AI model (Codex, Claude, etc.) Lib:Cluster DotNext.Net.Cluster library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TcpServer: timeout source returned to the pool twice after a TLS handshake (crash on shutdown)

2 participants