]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix timeout handling for incoming H2 w/ nghttp2
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 12 Jul 2023 12:40:34 +0000 (14:40 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 7 Sep 2023 08:22:04 +0000 (10:22 +0200)
pdns/dnsdist-tcp.cc

index 8d10e492575b0c506784e959f2843accacecd354..08ecf1d4fcaa6bba6bbfe636160ec51b8730b9c9 100644 (file)
@@ -1361,6 +1361,16 @@ static void tcpClientThread(pdns::channel::Receiver<ConnectionInfo>&& queryRecei
                 state->handleTimeout(state, false);
               }
             }
+#ifdef HAVE_NGHTTP2
+            else if (cbData.second.type() == typeid(std::shared_ptr<IncomingHTTP2Connection>)) {
+              auto state = boost::any_cast<std::shared_ptr<IncomingHTTP2Connection>>(cbData.second);
+              if (cbData.first == state->d_handler.getDescriptor()) {
+                vinfolog("Timeout (read) from remote H2 client %s", state->d_ci.remote.toStringWithPort());
+                std::shared_ptr<IncomingTCPConnectionState> parentState = state;
+                state->handleTimeout(parentState, false);
+              }
+            }
+#endif /* HAVE_NGHTTP2 */
             else if (cbData.second.type() == typeid(std::shared_ptr<TCPConnectionToBackend>)) {
               auto conn = boost::any_cast<std::shared_ptr<TCPConnectionToBackend>>(cbData.second);
               vinfolog("Timeout (read) from remote backend %s", conn->getBackendName());
@@ -1377,6 +1387,16 @@ static void tcpClientThread(pdns::channel::Receiver<ConnectionInfo>&& queryRecei
                 state->handleTimeout(state, true);
               }
             }
+#ifdef HAVE_NGHTTP2
+            else if (cbData.second.type() == typeid(std::shared_ptr<IncomingHTTP2Connection>)) {
+              auto state = boost::any_cast<std::shared_ptr<IncomingHTTP2Connection>>(cbData.second);
+              if (cbData.first == state->d_handler.getDescriptor()) {
+                vinfolog("Timeout (write) from remote H2 client %s", state->d_ci.remote.toStringWithPort());
+                std::shared_ptr<IncomingTCPConnectionState> parentState = state;
+                state->handleTimeout(parentState, true);
+              }
+            }
+#endif /* HAVE_NGHTTP2 */
             else if (cbData.second.type() == typeid(std::shared_ptr<TCPConnectionToBackend>)) {
               auto conn = boost::any_cast<std::shared_ptr<TCPConnectionToBackend>>(cbData.second);
               vinfolog("Timeout (write) from remote backend %s", conn->getBackendName());
@@ -1407,6 +1427,12 @@ static void tcpClientThread(pdns::channel::Receiver<ConnectionInfo>&& queryRecei
                   auto state = boost::any_cast<std::shared_ptr<IncomingTCPConnectionState>>(param);
                   errlog(" - %s", state->toString());
                 }
+#ifdef HAVE_NGHTTP2
+                else if (param.type() == typeid(std::shared_ptr<IncomingHTTP2Connection>)) {
+                  auto state = boost::any_cast<std::shared_ptr<IncomingHTTP2Connection>>(param);
+                  errlog(" - %s", state->toString());
+                }
+#endif /* HAVE_NGHTTP2 */
                 else if (param.type() == typeid(std::shared_ptr<TCPConnectionToBackend>)) {
                   auto conn = boost::any_cast<std::shared_ptr<TCPConnectionToBackend>>(param);
                   errlog(" - %s", conn->toString());
@@ -1506,7 +1532,7 @@ static void acceptNewConnection(const TCPAcceptorParam& param, TCPClientThreadDa
       gettimeofday(&now, nullptr);
 
       if (ci.cs->dohFrontend) {
-#ifdef HAVE_NGHTTP2        
+#ifdef HAVE_NGHTTP2
         auto state = std::make_shared<IncomingHTTP2Connection>(std::move(ci), *threadData, now);
         state->handleIO();
 #endif /* HAVE_NGHTTP2 */