Skip to content

Conversation

@AshkanAfsharpour
Copy link
Contributor

Fix potential CancellationTokenSource leak in HubConnection.cs #57232

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Summary of the changes (Less than 80 chars)

Fixes potential memory leak by ensuring proper disposal of CancellationTokenSource in HubConnection.cs.

Description

This PR addresses issue #57232 regarding a potential memory leak in HubConnection.cs where a CancellationTokenSource is created but only Cancel() is called without disposing it. As per the discussion, I've refactored the code to use the using var pattern to ensure automatic disposal of the CancellationTokenSource.

Fixes #57232.

@ghost ghost added the area-signalr Includes: SignalR clients and servers label Oct 8, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Oct 8, 2024
@AshkanAfsharpour
Copy link
Contributor Author

@AshkanAfsharpour please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@dotnet-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@dotnet-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@dotnet-policy-service agree company="Microsoft"

@dotnet-policy-service agree

@dotnet-policy-service agree

@BrennanConroy BrennanConroy merged commit d7101a3 into dotnet:main Oct 9, 2024
@BrennanConroy
Copy link
Member

Thanks @AshkanAfsharpour

@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview1 milestone Oct 9, 2024
@AshkanAfsharpour AshkanAfsharpour deleted the fix/issue-57232-cancellation-token-leak branch October 10, 2024 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-signalr Includes: SignalR clients and servers community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CancellationTokenSource potential leaks in SignalR HubConnection

2 participants