From b76db70a6c7876f80c04d9d4bc2c336b9be977bd Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 5 Nov 2019 01:16:22 +0100 Subject: [PATCH] Revert "cleanup: estimators: simplify blindAdjust" This reverts commit c699e7bec4405f232356e93e38d40e2bbfc76d24. --- dnscrypt-proxy/estimators.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dnscrypt-proxy/estimators.go b/dnscrypt-proxy/estimators.go index 47ca6ffd..461be79e 100644 --- a/dnscrypt-proxy/estimators.go +++ b/dnscrypt-proxy/estimators.go @@ -29,7 +29,11 @@ func (questionSizeEstimator *QuestionSizeEstimator) MinQuestionSize() int { func (questionSizeEstimator *QuestionSizeEstimator) blindAdjust() { questionSizeEstimator.Lock() - questionSizeEstimator.minQuestionSize = Min(MaxDNSUDPPacketSize, questionSizeEstimator.minQuestionSize*2) + if MaxDNSUDPPacketSize-questionSizeEstimator.minQuestionSize < questionSizeEstimator.minQuestionSize { + questionSizeEstimator.minQuestionSize = MaxDNSUDPPacketSize + } else { + questionSizeEstimator.minQuestionSize *= 2 + } questionSizeEstimator.ewma.Set(float64(questionSizeEstimator.minQuestionSize)) questionSizeEstimator.Unlock() }