From 9a17d3411db3ee41c9b8f1ff998c8f4474b7e9a0 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Thu, 9 Oct 2025 14:53:51 +0200 Subject: [PATCH] dnsdist: Properly handle exceptions when processing timeout rules Signed-off-by: Remi Gacogne --- pdns/dnsdistdist/dnsdist.cc | 72 +++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 30 deletions(-) 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()); } } } -- 2.47.3