Merge remote-tracking branch 'origin/topic/awelzel/dns-mgr-fixes'

* origin/topic/awelzel/dns-mgr-fixes:
  DNS_Mgr: Use Process() for timeout expiration
  DNS_Mgr: Fix GetNextTimeout() returning absolute values
This commit is contained in:
Arne Welzel 2023-09-05 19:56:59 +02:00
commit 1441b83411
4 changed files with 31 additions and 4 deletions

19
CHANGES
View file

@ -1,3 +1,22 @@
6.1.0-dev.364 | 2023-09-05 19:56:59 +0200
* DNS_Mgr: Use Process() for timeout expiration (Arne Welzel, Corelight)
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).
* DNS_Mgr: Fix GetNextTimeout() returning absolute values (Arne Welzel, Corelight)
Not sure, must have been some sort of left-over, but wasn't really
effective due to Process() not being implemented.
6.1.0-dev.361 | 2023-09-04 14:00:37 +0200 6.1.0-dev.361 | 2023-09-04 14:00:37 +0200
* Fix check for emailed notices (Justin Azoff, Corelight) * Fix check for emailed notices (Justin Azoff, Corelight)

View file

@ -1 +1 @@
6.1.0-dev.361 6.1.0-dev.364

View file

@ -1456,8 +1456,7 @@ double DNS_Mgr::GetNextTimeout()
struct timeval* tvp = ares_timeout(channel, &tv, &tv); struct timeval* tvp = ares_timeout(channel, &tv, &tv);
return run_state::network_time + static_cast<double>(tvp->tv_sec) + return static_cast<double>(tvp->tv_sec) + (static_cast<double>(tvp->tv_usec) / 1e6);
(static_cast<double>(tvp->tv_usec) / 1e6);
} }
void DNS_Mgr::ProcessFd(int fd, int flags) void DNS_Mgr::ProcessFd(int fd, int flags)
@ -1472,6 +1471,15 @@ void DNS_Mgr::ProcessFd(int fd, int flags)
IssueAsyncRequests(); 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) void DNS_Mgr::GetStats(Stats* stats)
{ {
// TODO: can this use the telemetry framework? // TODO: can this use the telemetry framework?

View file

@ -285,7 +285,7 @@ protected:
void IssueAsyncRequests(); void IssueAsyncRequests();
// IOSource interface. // IOSource interface.
void Process() override { } void Process() override;
void ProcessFd(int fd, int flags) override; void ProcessFd(int fd, int flags) override;
void InitSource() override; void InitSource() override;
const char* Tag() override { return "DNS_Mgr"; } const char* Tag() override { return "DNS_Mgr"; }