]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Only call setDropOnIdle() if we're actually have a tcp connection.
authorOtto <otto.moerbeek@open-xchange.com>
Fri, 26 Nov 2021 10:40:32 +0000 (11:40 +0100)
committerOtto <otto.moerbeek@open-xchange.com>
Fri, 26 Nov 2021 10:40:32 +0000 (11:40 +0100)
Also add extra consistency check, d_tcp and d_tcpcOnnection should
likely be squashed into a single thing.

pdns/pdns_recursor.cc

index 380fc1cb95ba58559a702d0f3f1885ac91a2416a..35b9d929889ac9edc4b266fa75a4f388eccd2d31 100644 (file)
@@ -1154,6 +1154,9 @@ static bool addRecordToPacket(DNSPacketWriter& pw, const DNSRecord& rec, uint32_
 class RunningResolveGuard {
 public:
   RunningResolveGuard(std::unique_ptr<DNSComboWriter>& dc) : d_dc(dc) {
+    if (d_dc->d_tcp && !d_dc->d_tcpConnection) {
+      throw std::runtime_error("incoming TCP case without TCP connection");
+    }
   }
   ~RunningResolveGuard() {
     if (!d_handled && d_dc->d_tcp) {
@@ -1164,7 +1167,9 @@ public:
     d_handled = true;
   }
   void setDropOnIdle() {
-    d_dc->d_tcpConnection->setDropOnIdle();
+    if (d_dc->d_tcp) {
+      d_dc->d_tcpConnection->setDropOnIdle();
+    }
   }
 private:
   std::unique_ptr<DNSComboWriter>& d_dc;