]> 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, 28 Aug 2025 08:43:44 +0000 (10:43 +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>
(cherry picked from commit e0a5a6dc4ab9557442ddbba56d03f6e4fb132bf2)

pdns/dnsdistdist/dnsdist-nghttp2-in.cc

index d62846829bfd24ae74d634f80afaed27011b6f3b..a188d58c781616ba432c5ab441857c26f0c6bf76 100644 (file)
@@ -440,6 +440,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) {
@@ -1237,6 +1255,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()