]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Reduce useless wake-ups from the event loop 12276/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 18 Nov 2022 15:56:16 +0000 (16:56 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 6 Dec 2022 11:06:07 +0000 (12:06 +0100)
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.

pdns/dnsdist-tcp.cc
pdns/dnsdist.cc
pdns/dnsdistdist/dnsdist-backend.cc
pdns/dnsdistdist/dnsdist-lua-network.cc
pdns/dnsdistdist/dnsdist-nghttp2.cc

index c9f4120b7720c7f0ab04896e7b11e0d6f6d1c49d..13d6352f9387c3f8d50d01449eaeefddc693cf6c 100644 (file)
@@ -1526,7 +1526,7 @@ void tcpAcceptorThread(std::vector<ClientState*> states)
 
     struct timeval tv;
     while (true) {
-      mplexer->run(&tv);
+      mplexer->run(&tv, -1);
     }
   }
 }
index d0b3fbec937d059a47ce3bf8352722d828690350..6cd5b86af5911ee3c704ca392f819532d0e890db 100644 (file)
@@ -1818,7 +1818,7 @@ static void udpClientThread(std::vector<ClientState*> states)
 
         struct timeval tv;
         while (true) {
-          mplexer->run(&tv);
+          mplexer->run(&tv, -1);
         }
       }
     }
index 562cb8abe84026f7be73a61583b63aaf7e6e7695..f38dc505b78c0a784ebb474edd8ddcd5a76bdff9 100644 (file)
@@ -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(); ) {
index 4165025c665437a357139f643f0e2d0d32c5c4b0..819137a400fc50081a0a181f9be0852db4eb75bb 100644 (file)
@@ -134,7 +134,7 @@ void NetworkListener::mainThread()
   struct timeval now;
 
   while (true) {
-    runOnce(now, 5000);
+    runOnce(now, -1);
   }
 }
 
index 361fc087c5c1680a401056cecafb91feee551ac3..c57a361fce1e488bc0b6281db13f899e353566e6 100644 (file)
@@ -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;