浏览代码

release semaphore

老九 3 年之前
父节点
当前提交
baf0d2f304
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      FastGithub.DomainResolve/DnsClient.cs

+ 6 - 2
FastGithub.DomainResolve/DnsClient.cs

@@ -117,9 +117,9 @@ namespace FastGithub.DomainResolve
                 return true;
             }
 
-            if (this.dnsStateCache.TryGetValue<bool>(dns, out var state))
+            if (this.dnsStateCache.TryGetValue<bool>(dns, out var available))
             {
-                return state;
+                return available;
             }
 
             var key = dns.ToString();
@@ -139,6 +139,10 @@ namespace FastGithub.DomainResolve
                 cancellationToken.ThrowIfCancellationRequested();
                 return this.dnsStateCache.Set(dns, false, this.stateExpiration);
             }
+            finally
+            {
+                semaphore.Release();
+            }
         }
 
         /// <summary>