diff options
Diffstat (limited to '')
-rw-r--r-- | LibMatrix/Services/HomeserverResolverService.cs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/LibMatrix/Services/HomeserverResolverService.cs b/LibMatrix/Services/HomeserverResolverService.cs index 78c5c37..dcd0fe9 100644 --- a/LibMatrix/Services/HomeserverResolverService.cs +++ b/LibMatrix/Services/HomeserverResolverService.cs @@ -1,4 +1,10 @@ +using System; +using System.Collections.Generic; +using System.IO; using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using ArcaneLibs.Extensions; using LibMatrix.Extensions; using Microsoft.Extensions.Logging; @@ -26,9 +32,9 @@ public class HomeserverResolverService { if (homeserver is null) throw new ArgumentNullException(nameof(homeserver)); var sem = _wellKnownSemaphores.GetOrCreate(homeserver, _ => new SemaphoreSlim(1, 1)); await sem.WaitAsync(); - if (_wellKnownCache.ContainsKey(homeserver)) { + if (_wellKnownCache.TryGetValue(homeserver, out var known)) { sem.Release(); - return _wellKnownCache[homeserver]; + return known; } string? result = null; |