Skip to content

Commit

Permalink
DNS_Mgr: Use Process() for timeout expiration
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
awelzel committed Sep 4, 2023
1 parent 62c06f7 commit 70a62d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/DNS_Mgr.cc
Expand Up @@ -1471,6 +1471,14 @@ void DNS_Mgr::ProcessFd(int fd, int flags)
IssueAsyncRequests();
}

void DNS_Mgr::Process()
{
// Kick off timeout management: Process() is called if
// DNS_Mgr is called without an active FD when its
// GetNextTimeout() reaches 0.
ares_process_fd(channel, ARES_SOCKET_BAD, ARES_SOCKET_BAD);
}

void DNS_Mgr::GetStats(Stats* stats)
{
// TODO: can this use the telemetry framework?
Expand Down
2 changes: 1 addition & 1 deletion src/DNS_Mgr.h
Expand Up @@ -285,7 +285,7 @@ class DNS_Mgr : public iosource::IOSource
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"; }
Expand Down

0 comments on commit 70a62d5

Please sign in to comment.