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

Fix MsQuicConfiguration.GetConfigurationCacheEnabled #101555

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,23 @@ internal static partial class MsQuicConfiguration
private const string DisableCacheCtxSwitch = "System.Net.Quic.DisableConfigurationCache";

internal static bool ConfigurationCacheEnabled { get; } = GetConfigurationCacheEnabled();

private static bool GetConfigurationCacheEnabled()
{
// AppContext switch takes precedence
if (AppContext.TryGetSwitch(DisableCacheCtxSwitch, out bool value))
{
return !value;
}
else
// check environment variable second
else if (Environment.GetEnvironmentVariable(DisableCacheEnvironmentVariable) is string envVar)
{
// check environment variable
return
Environment.GetEnvironmentVariable(DisableCacheEnvironmentVariable) is string envVar &&
!(envVar == "1" || envVar.Equals("true", StringComparison.OrdinalIgnoreCase));
return !(envVar == "1" || envVar.Equals("true", StringComparison.OrdinalIgnoreCase));
}
}

// enabled by default
return true;
}
private static readonly ConcurrentDictionary<CacheKey, MsQuicConfigurationSafeHandle> s_configurationCache = new();

private readonly struct CacheKey : IEquatable<CacheKey>
Expand Down
Loading