From 14843f11e21ad5b5c7d06241c11851804f194206 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Tue, 26 Apr 2022 09:50:50 +0200 Subject: [PATCH] dnsdist: Scan the UDP buckets only when we have outstanding queries --- pdns/dnsdistdist/dnsdist-backend.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) 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); + } } } } -- 2.47.2