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

AsyncState can be used across different service providers #4966

Merged

Conversation

mobratil
Copy link
Contributor

@mobratil mobratil commented Feb 23, 2024

Current implementation of AsyncState has problems.
This PR fixes #4959 by making the field _contextCount static.

Microsoft Reviewers: Open in CodeFlow

Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

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

Few more issues to tackle

@RussKie RussKie added the waiting-author-feedback 📭 The author of this issue needs to respond in order for us to continue investigating this issue. label Feb 23, 2024
…est.

Added comment to warning disable.

Added header to AssemblyInfo.cs
@dotnet-policy-service dotnet-policy-service bot removed the waiting-author-feedback 📭 The author of this issue needs to respond in order for us to continue investigating this issue. label Feb 23, 2024
@sebastienros
Copy link
Member

The counter is always increasing and declared as int. Is the counter tied to the pool, meaning that it won't increase more than the number of pooled objects, or is it incremented with each AsyncState resolution (multiple times per request) and possibly exceeding the int capacity?

@mobratil
Copy link
Contributor Author

@sebastienros Yes, the int is increasing but only when we create a new instance of AsyncContext<>. But we register these types as singletons (

services.TryAddSingleton(typeof(IAsyncContext<>), typeof(AsyncContext<>));
) so there's limited number of these instances.

@mobratil mobratil merged commit 043b5e5 into main Feb 29, 2024
6 checks passed
@mobratil mobratil deleted the 4959-asyncstate-breaks-when-used-in-multiple-service-collections branch February 29, 2024 16:59
@xakep139 xakep139 added this to the 8.3 milestone Mar 7, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AsyncState breaks when used in multiple service collections
4 participants