Skip to content

Fix disposed scope on TCP request timeout - #294

Open
Kowjako wants to merge 1 commit into
dotnet:masterfrom
Kowjako:fix/tcp-timeout-disposed-scope
Open

Fix disposed scope on TCP request timeout#294
Kowjako wants to merge 1 commit into
dotnet:masterfrom
Kowjako:fix/tcp-timeout-disposed-scope

Conversation

@Kowjako

Copy link
Copy Markdown

Summary

  • Handle TCP request timeouts while the multiplexed cancellation scope is still valid.
  • Keep lifecycle-triggered cancellation silent during graceful server shutdown.
  • Add a regression test that times out a vote request and verifies that the server accepts a subsequent connection.

Root cause

TcpServer.HandleConnection disposed timeoutSource in the per-request finally block and then inspected that scope in the outer OperationCanceledException handler. Because the cancellation source is pooled, CausedByTimeout could access an already disposed source and throw ObjectDisposedException from the async void connection handler.

Implementation

  • Classify and log request timeouts before disposing timeoutSource in TcpServer.cs (lines 134-138).
  • Leave the outer cancellation handler responsible only for silent connection shutdown in TcpServer.cs (line 150).
  • Extend the transport test member with a cancellable vote delay in TransportTestSuite.cs (lines 41 and 128-140).
  • Add a TCP regression test that verifies recovery after the timed-out request in TcpTransportTests.cs (lines 99-119).

Validation

  • git diff --check
  • Build and tests were not run because the repository instructions explicitly prohibit running .NET builds.

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.

1 participant

@Kowjako