Skip to content

Commit

Permalink
Fix MsQuicConfiguration.GetConfigurationCacheEnabled (dotnet#101555)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzikm authored and Ruihan-Yin committed May 30, 2024
1 parent d4fd919 commit d62a539
Showing 1 changed file with 7 additions and 6 deletions.
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

0 comments on commit d62a539

Please sign in to comment.