From: Remi Gacogne Date: Fri, 18 Nov 2022 15:56:16 +0000 (+0100) Subject: dnsdist: Reduce useless wake-ups from the event loop X-Git-Tag: dnsdist-1.8.0-rc1~195^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F12276%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Reduce useless wake-ups from the event loop The TCP acceptor, UDP client and Lua network threads never needs to break out of the event loop. The outgoing DoH one only needs to do that once per second to check for timeouts. --- diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index c9f4120b77..13d6352f93 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -1526,7 +1526,7 @@ void tcpAcceptorThread(std::vector states) struct timeval tv; while (true) { - mplexer->run(&tv); + mplexer->run(&tv, -1); } } } diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index d0b3fbec93..6cd5b86af5 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -1818,7 +1818,7 @@ static void udpClientThread(std::vector states) struct timeval tv; while (true) { - mplexer->run(&tv); + mplexer->run(&tv, -1); } } } diff --git a/pdns/dnsdistdist/dnsdist-backend.cc b/pdns/dnsdistdist/dnsdist-backend.cc index 562cb8abe8..f38dc505b7 100644 --- a/pdns/dnsdistdist/dnsdist-backend.cc +++ b/pdns/dnsdistdist/dnsdist-backend.cc @@ -377,6 +377,10 @@ void DownstreamState::reportTimeoutOrError() void DownstreamState::handleUDPTimeouts() { + if (getProtocol() != dnsdist::Protocol::DoUDP) { + return; + } + if (s_randomizeIDs) { auto map = d_idStatesMap.lock(); for (auto it = map->begin(); it != map->end(); ) { diff --git a/pdns/dnsdistdist/dnsdist-lua-network.cc b/pdns/dnsdistdist/dnsdist-lua-network.cc index 4165025c66..819137a400 100644 --- a/pdns/dnsdistdist/dnsdist-lua-network.cc +++ b/pdns/dnsdistdist/dnsdist-lua-network.cc @@ -134,7 +134,7 @@ void NetworkListener::mainThread() struct timeval now; while (true) { - runOnce(now, 5000); + runOnce(now, -1); } } diff --git a/pdns/dnsdistdist/dnsdist-nghttp2.cc b/pdns/dnsdistdist/dnsdist-nghttp2.cc index 361fc087c5..c57a361fce 100644 --- a/pdns/dnsdistdist/dnsdist-nghttp2.cc +++ b/pdns/dnsdistdist/dnsdist-nghttp2.cc @@ -909,7 +909,7 @@ static void dohClientThread(int crossProtocolPipeFD) time_t lastTimeoutScan = now.tv_sec; for (;;) { - data.mplexer->run(&now); + data.mplexer->run(&now, 1000); if (now.tv_sec > lastTimeoutScan) { lastTimeoutScan = now.tv_sec;