From a57c45428f3a8ccc1346341f44ae3854e83bc543 Mon Sep 17 00:00:00 2001 From: Arne Welzel Date: Mon, 4 Sep 2023 17:33:43 +0200 Subject: [PATCH] DNS_Mgr: Use Process() for timeout expiration DNS_Mgr has a GetNextTimeout() implementation that may return 0.0. When that is the case, its IO source is enqueued as ready with an fd of -1. This in turn results in Process() being called instead of ProcessFd() in RunState.cc. Ensure timeouts behavior is properly handled by actually forwarding timeout indications to c-ares via DNS_Mgr::Process(). This results in pending DNS queries for which a timeout happened to actually timeout (when there's no other connectivity). --- src/DNS_Mgr.cc | 9 +++++++++ src/DNS_Mgr.h | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/DNS_Mgr.cc b/src/DNS_Mgr.cc index a79a524b34..9b06eb3f8b 100644 --- a/src/DNS_Mgr.cc +++ b/src/DNS_Mgr.cc @@ -1471,6 +1471,15 @@ void DNS_Mgr::ProcessFd(int fd, int flags) IssueAsyncRequests(); } +void DNS_Mgr::Process() + { + // Process() is called when DNS_Mgr is found "ready" when its + // GetNextTimeout() returns 0.0, but there's no active FD. + // + // Kick off timeouts at least. + ares_process_fd(channel, ARES_SOCKET_BAD, ARES_SOCKET_BAD); + } + void DNS_Mgr::GetStats(Stats* stats) { // TODO: can this use the telemetry framework? diff --git a/src/DNS_Mgr.h b/src/DNS_Mgr.h index 97ca1c23f8..5f87313e95 100644 --- a/src/DNS_Mgr.h +++ b/src/DNS_Mgr.h @@ -285,7 +285,7 @@ protected: void IssueAsyncRequests(); // IOSource interface. - void Process() override { } + void Process() override; void ProcessFd(int fd, int flags) override; void InitSource() override; const char* Tag() override { return "DNS_Mgr"; }