Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add | Adding disposable stack temp ref struct and use #1818

Merged
merged 2 commits into from
Nov 3, 2022

Conversation

Wraith2
Copy link
Contributor

@Wraith2 Wraith2 commented Oct 25, 2022

fixes #1810

Adds a mutable ref struct to hold disposable things. The cancellation token registration is created and put into the struct. If the code reaches a Take method the value is taken by the caller. If the finally block of the using scope is reached while the value is still held the value will be disposed. This ensures that either the registration is passed to the context object or is correctly disposed.

@codecov
Copy link

codecov bot commented Oct 25, 2022

Codecov Report

Base: 71.38% // Head: 71.69% // Increases project coverage by +0.31% 🎉

Coverage data is based on head (1682b89) compared to base (20d4c19).
Patch coverage: 76.76% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1818      +/-   ##
==========================================
+ Coverage   71.38%   71.69%   +0.31%     
==========================================
  Files         290      291       +1     
  Lines       61236    62406    +1170     
==========================================
+ Hits        43712    44742    +1030     
- Misses      17524    17664     +140     
Flag Coverage Δ
addons 92.38% <ø> (ø)
netcore 75.29% <84.12%> (+0.28%) ⬆️
netfx 69.58% <72.91%> (+0.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...etfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs 68.46% <63.88%> (+0.04%) ⬆️
...core/src/Microsoft/Data/SqlClient/SqlDataReader.cs 75.52% <80.39%> (+2.73%) ⬆️
...osoft/Data/SqlClient/DisposableTemporaryOnStack.cs 100.00% <100.00%> (ø)
...core/src/Microsoft/Data/SqlClient/SNI/SNIHandle.cs 35.71% <0.00%> (-6.40%) ⬇️
.../src/Microsoft/Data/SqlClient/SNI/SNIMarsHandle.cs 87.89% <0.00%> (-4.49%) ⬇️
...osoft/Data/SqlClient/TdsParserStateObjectNative.cs 86.77% <0.00%> (-0.93%) ⬇️
...lient/src/Microsoft/Data/SqlClient/SqlParameter.cs 75.17% <0.00%> (-0.33%) ⬇️
.../netcore/src/Microsoft/Data/SqlClient/TdsParser.cs 73.37% <0.00%> (-0.18%) ⬇️
...c/Microsoft/Data/SqlClient/TdsParserStateObject.cs 81.57% <0.00%> (ø)
...nt/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs 71.05% <0.00%> (+<0.01%) ⬆️
... and 16 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@JRahnama
Copy link
Member

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@lcheunglci lcheunglci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Wraith2 , LGTM

@JRahnama JRahnama added this to the 5.1.0-preview2 milestone Nov 3, 2022
@JRahnama
Copy link
Member

JRahnama commented Nov 3, 2022

/Azurepipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@JRahnama JRahnama changed the title Add disposable stack temp ref struct and use Add | Adding disposable stack temp ref struct and use Nov 3, 2022
@JRahnama
Copy link
Member

JRahnama commented Nov 3, 2022

@Wraith2 that failure on Mac machine is a bit concerning. Probably if I rerun it that will pass, but this test should not fail randomly, the failure mentions this as a critical issue.

@Wraith2
Copy link
Contributor Author

Wraith2 commented Nov 3, 2022

It was all green before I removed some spaces...

The error is in mars concurrency and despite what the message says, that it shouldn't fail randomly, concurrency tests are hard to write and keep stable. Nothing in this change set should have any effect on concurrency or mars.

@JRahnama JRahnama merged commit 760510c into dotnet:main Nov 3, 2022
@JRahnama
Copy link
Member

JRahnama commented Nov 3, 2022

We should spend some time in near future look into Active issues, some of them might not be an issue anymore, and also find a solution for these kinds of intermittent failures.

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.

CancellationToken registration leak, regression
4 participants