]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Stop reading on incoming DoH sockets if we are done
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 28 Jul 2025 14:33:46 +0000 (16:33 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 21 Aug 2025 10:28:38 +0000 (12:28 +0200)
If the underlying library doesn't want to read, we have nothing
to send at the moment, but we are still waiting for responses,
there is no need to keep polling the socket.

Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsdistdist/dnsdist-nghttp2-in.cc

index 56d6c52a852c4ec904e5f2e107d2f331319ff2d0..3cc0451506e9a3b7983e17621a124a3c3e31b703 100644 (file)
@@ -443,6 +443,24 @@ void IncomingHTTP2Connection::handleIO()
       if (nghttp2_session_want_read(d_session.get()) != 0) {
         updateIO(IOState::NeedRead, handleReadableIOCallback);
       }
+      else {
+        if (getConcurrentStreamsCount() == 0) {
+          d_connectionDied = true;
+          stopIO();
+        }
+        else {
+          updateIO(IOState::Done, handleReadableIOCallback);
+        }
+      }
+    }
+    else {
+      if (getConcurrentStreamsCount() == 0) {
+        d_connectionDied = true;
+        stopIO();
+      }
+      else {
+        updateIO(IOState::Done, handleReadableIOCallback);
+      }
     }
   }
   catch (const std::exception& e) {
@@ -1263,6 +1281,9 @@ void IncomingHTTP2Connection::updateIO(IOState newState, const FDMultiplexer::ca
     ttd = getClientWriteTTD(now);
     d_ioState->update(newState, callback, shared, ttd);
   }
+  else if (newState == IOState::Done) {
+    d_ioState->reset();
+  }
 }
 
 void IncomingHTTP2Connection::handleIOError()