From baf0d2f304f24842464be5d612d6faea6ccf0509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E4=B9=9D?= <366193849@qq.com> Date: Fri, 3 Dec 2021 23:26:59 +0800 Subject: [PATCH] release semaphore --- FastGithub.DomainResolve/DnsClient.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/FastGithub.DomainResolve/DnsClient.cs b/FastGithub.DomainResolve/DnsClient.cs index 162f34c..e96bc88 100644 --- a/FastGithub.DomainResolve/DnsClient.cs +++ b/FastGithub.DomainResolve/DnsClient.cs @@ -117,9 +117,9 @@ namespace FastGithub.DomainResolve return true; } - if (this.dnsStateCache.TryGetValue(dns, out var state)) + if (this.dnsStateCache.TryGetValue(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(); + } } ///