From 8e2cec124aa4c6257297bb63fa96455ab6c298c8 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Thu, 11 Aug 2022 13:33:15 +0530 Subject: [PATCH] DnsServer: updated code for stats manager related changes. --- DnsServerCore/Dns/DnsServer.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DnsServerCore/Dns/DnsServer.cs b/DnsServerCore/Dns/DnsServer.cs index dcd44ca9..20d21c36 100644 --- a/DnsServerCore/Dns/DnsServer.cs +++ b/DnsServerCore/Dns/DnsServer.cs @@ -172,8 +172,8 @@ namespace DnsServerCore.Dns Timer _qpmLimitSamplingTimer; readonly object _qpmLimitSamplingTimerLock = new object(); const int QPM_LIMIT_SAMPLING_TIMER_INTERVAL = 10000; - IReadOnlyDictionary _qpmLimitClientSubnetStats; - IReadOnlyDictionary _qpmLimitErrorClientSubnetStats; + IReadOnlyDictionary _qpmLimitClientSubnetStats; + IReadOnlyDictionary _qpmLimitErrorClientSubnetStats; readonly IndependentTaskScheduler _resolverTaskScheduler = new IndependentTaskScheduler(ThreadPriority.AboveNormal); readonly DomainTree> _resolverTasks = new DomainTree>(); @@ -2746,11 +2746,11 @@ namespace DnsServerCore.Dns { try { - List> eligibleQueries = _stats.GetLastHourEligibleQueries(_cachePrefetchSampleEligibilityHitsPerHour); + List> eligibleQueries = _stats.GetLastHourEligibleQueries(_cachePrefetchSampleEligibilityHitsPerHour); List cacheRefreshSampleList = new List(eligibleQueries.Count); int cacheRefreshTrigger = (_cachePrefetchSampleIntervalInMinutes + 1) * 60; - foreach (KeyValuePair eligibleQuery in eligibleQueries) + foreach (KeyValuePair eligibleQuery in eligibleQueries) { DnsQuestionRecord eligibleQuerySample = eligibleQuery.Key; @@ -2964,16 +2964,16 @@ namespace DnsServerCore.Dns throw new NotSupportedException("AddressFamily not supported."); } - if ((_qpmLimitErrors > 0) && (_qpmLimitErrorClientSubnetStats is not null) && _qpmLimitErrorClientSubnetStats.TryGetValue(remoteSubnet, out int errorCountPerSample)) + if ((_qpmLimitErrors > 0) && (_qpmLimitErrorClientSubnetStats is not null) && _qpmLimitErrorClientSubnetStats.TryGetValue(remoteSubnet, out long errorCountPerSample)) { - int averageErrorCountPerMinute = errorCountPerSample / _qpmLimitSampleMinutes; + long averageErrorCountPerMinute = errorCountPerSample / _qpmLimitSampleMinutes; if (averageErrorCountPerMinute >= _qpmLimitErrors) return true; } - if ((_qpmLimitRequests > 0) && (_qpmLimitClientSubnetStats is not null) && _qpmLimitClientSubnetStats.TryGetValue(remoteSubnet, out int countPerSample)) + if ((_qpmLimitRequests > 0) && (_qpmLimitClientSubnetStats is not null) && _qpmLimitClientSubnetStats.TryGetValue(remoteSubnet, out long countPerSample)) { - int averageCountPerMinute = countPerSample / _qpmLimitSampleMinutes; + long averageCountPerMinute = countPerSample / _qpmLimitSampleMinutes; if (averageCountPerMinute >= _qpmLimitRequests) return true; }