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

Dispose SignatureProviders after moving to staging cache. #2682

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

brentschmaltz
Copy link
Member

This change solves a couple of issues.

  1. A race condition where a SignatureProvider was disposed but was still able to be obtained from the cache.
  2. SignatureProviders were not disposed when compacting, which results in a number of objects on the finalizer Q.

SignatureProviders are ref counted, but not removed and disposed when the ref count goes to zero. The logic is most likely the SignatureProvider will be used again in a short period.

The significant change is that on compaction SignatureProviders are moved to a 'compactCache'. Periodically, the 'compactCache' is examined for SignatureProviders that can be disposed.

The CryptoProviderFactory will never return a SignatureProvider from the 'compactCache' when asked to create a SignatureProvider.

SignatureProviders that were not cached, will be disposed when released.

It is helpful when reviewing, all tasks are run in serial on a background task.

@brentschmaltz brentschmaltz requested a review from a team as a code owner July 3, 2024 19:32
@brentschmaltz brentschmaltz force-pushed the brentsch/AsymmetricDispose branch from cf409fd to dd91270 Compare July 8, 2024 21:15
Move compacted SignatureProviders to new cache to ensure dispose is called.
Add delegate to check if signature provider should be removed from cache.
Separate expired from compaction
Dispose SignatureProvider if it was never cached.
@brentschmaltz brentschmaltz force-pushed the brentsch/AsymmetricDispose branch from 07a4b92 to 5e5a5db Compare July 20, 2024 01:39
@brentschmaltz brentschmaltz merged commit 49a3a95 into dev Jul 22, 2024
4 checks passed
@brentschmaltz brentschmaltz deleted the brentsch/AsymmetricDispose branch July 22, 2024 15:23
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.

7 participants