From: Remi Gacogne Date: Thu, 9 Oct 2025 12:53:51 +0000 (+0200) Subject: dnsdist: Properly handle exceptions when processing timeout rules X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16238%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Properly handle exceptions when processing timeout rules Signed-off-by: Remi Gacogne --- diff --git a/pdns/dnsdistdist/dnsdist.cc b/pdns/dnsdistdist/dnsdist.cc index a1e58df1c7..c06c42acf5 100644 --- a/pdns/dnsdistdist/dnsdist.cc +++ b/pdns/dnsdistdist/dnsdist.cc @@ -1611,7 +1611,14 @@ bool handleTimeoutResponseRules(const std::vector mplexer{nullptr}; - const auto& runtimeConfig = dnsdist::configuration::refreshLocalRuntimeConfiguration(); + std::unique_ptr mplexer{nullptr}; + const auto& runtimeConfig = dnsdist::configuration::refreshLocalRuntimeConfiguration(); - // this points to the actual shared_ptrs! - // coverity[auto_causes_copy] - const auto servers = runtimeConfig.d_backends; - for (const auto& dss : servers) { - dss->updateStatisticsInfo(); + // this points to the actual shared_ptrs! + // coverity[auto_causes_copy] + const auto servers = runtimeConfig.d_backends; + for (const auto& dss : servers) { + dss->updateStatisticsInfo(); - dss->handleUDPTimeouts(); + dss->handleUDPTimeouts(); - if (!dss->healthCheckRequired()) { - continue; - } + if (!dss->healthCheckRequired()) { + continue; + } + + if (!mplexer) { + mplexer = std::unique_ptr(FDMultiplexer::getMultiplexerSilent(servers.size())); + } - if (!mplexer) { - mplexer = std::unique_ptr(FDMultiplexer::getMultiplexerSilent(servers.size())); + if (!queueHealthCheck(mplexer, dss)) { + dss->submitHealthCheckResult(false, false); + } } - if (!queueHealthCheck(mplexer, dss)) { - dss->submitHealthCheckResult(false, false); + if (mplexer) { + handleQueuedHealthChecks(*mplexer); } } - - if (mplexer) { - handleQueuedHealthChecks(*mplexer); + catch (const std::exception& exp) { + vinfolog("Exception in the health-check thread: %s", exp.what()); } } }