From 18a9a76dcda5fe2e8c44081e3f001f1c9741bf89 Mon Sep 17 00:00:00 2001 From: rootdarkarchon Date: Tue, 27 Dec 2022 23:51:41 +0100 Subject: [PATCH] remove semaphore --- .../Services/MareConfigurationServiceClient.cs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/MareSynchronosServer/MareSynchronosShared/Services/MareConfigurationServiceClient.cs b/MareSynchronosServer/MareSynchronosShared/Services/MareConfigurationServiceClient.cs index 39d014b..0f858e2 100644 --- a/MareSynchronosServer/MareSynchronosShared/Services/MareConfigurationServiceClient.cs +++ b/MareSynchronosServer/MareSynchronosShared/Services/MareConfigurationServiceClient.cs @@ -20,7 +20,6 @@ public class MareConfigurationServiceClient : IConfigurationService where private readonly ILogger> _logger; private readonly GrpcClientFactory _grpcClientFactory; private readonly string _grpcClientName; - private static readonly SemaphoreSlim _readLock = new(1); public MareConfigurationServiceClient(ILogger> logger, IOptions config, GrpcClientFactory grpcClientFactory, string grpcClientName) { @@ -40,10 +39,8 @@ public class MareConfigurationServiceClient : IConfigurationService where bool isRemote = prop.GetCustomAttributes(typeof(RemoteConfigurationAttribute), inherit: true).Any(); if (isRemote) { - _readLock.Wait(); if (_cachedRemoteProperties.TryGetValue(key, out var existingEntry)) { - _readLock.Release(); return (T1)_cachedRemoteProperties[key].Value; } @@ -67,10 +64,6 @@ public class MareConfigurationServiceClient : IConfigurationService where return defaultValue; } } - finally - { - _readLock.Release(); - } } var value = prop.GetValue(_config); @@ -103,10 +96,8 @@ public class MareConfigurationServiceClient : IConfigurationService where bool isRemote = prop.GetCustomAttributes(typeof(RemoteConfigurationAttribute), inherit: true).Any(); if (isRemote) { - _readLock.Wait(); - if (_cachedRemoteProperties.TryGetValue(key, out var existingEntry) && existingEntry.Inserted > DateTime.Now - TimeSpan.FromMinutes(60)) + if (_cachedRemoteProperties.TryGetValue(key, out var existingEntry)) { - _readLock.Release(); return (T1)_cachedRemoteProperties[key].Value; } @@ -130,10 +121,6 @@ public class MareConfigurationServiceClient : IConfigurationService where throw new KeyNotFoundException(key); } } - finally - { - _readLock.Release(); - } } var value = prop.GetValue(_config);