From: Remi Gacogne Date: Tue, 26 Apr 2022 07:50:50 +0000 (+0200) Subject: dnsdist: Scan the UDP buckets only when we have outstanding queries X-Git-Tag: auth-4.8.0-alpha0~113^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F11577%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Scan the UDP buckets only when we have outstanding queries --- diff --git a/pdns/dnsdistdist/dnsdist-backend.cc b/pdns/dnsdistdist/dnsdist-backend.cc index 25dd110345..ac655111fa 100644 --- a/pdns/dnsdistdist/dnsdist-backend.cc +++ b/pdns/dnsdistdist/dnsdist-backend.cc @@ -357,16 +357,18 @@ void DownstreamState::handleTimeouts() } } else { - for (IDState& ids : idStates) { - int64_t usageIndicator = ids.usageIndicator; - if (IDState::isInUse(usageIndicator) && isIDSExpired(ids)) { - if (!ids.tryMarkUnused(usageIndicator)) { - /* this state has been altered in the meantime, - don't go anywhere near it */ - continue; - } + if (outstanding.load() > 0) { + for (IDState& ids : idStates) { + int64_t usageIndicator = ids.usageIndicator; + if (IDState::isInUse(usageIndicator) && isIDSExpired(ids)) { + if (!ids.tryMarkUnused(usageIndicator)) { + /* this state has been altered in the meantime, + don't go anywhere near it */ + continue; + } - handleTimeout(ids); + handleTimeout(ids); + } } } }