about summary refs log tree commit diff
path: root/LibMatrix/Services/HomeserverResolverService.cs
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-09-04 02:17:10 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-09-04 02:17:10 +0200
commit21da6cde79ccd0cb7f895a29e3d8cab959ef11ba (patch)
treefb0b89566b64ae907d7ca3ea8a29adcf0c0361d0 /LibMatrix/Services/HomeserverResolverService.cs
parentClean up some extension functions (diff)
downloadLibMatrix-21da6cde79ccd0cb7f895a29e3d8cab959ef11ba.tar.xz
Too many changes to name...
Diffstat (limited to 'LibMatrix/Services/HomeserverResolverService.cs')
-rw-r--r--LibMatrix/Services/HomeserverResolverService.cs10
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;