From: Otto Date: Fri, 26 Nov 2021 10:40:32 +0000 (+0100) Subject: Only call setDropOnIdle() if we're actually have a tcp connection. X-Git-Tag: rec-4.7.0-alpha0~13^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b7fde0e039421b6bd9aa0f15bce074a81108f4d;p=thirdparty%2Fpdns.git Only call setDropOnIdle() if we're actually have a tcp connection. Also add extra consistency check, d_tcp and d_tcpcOnnection should likely be squashed into a single thing. --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 380fc1cb95..35b9d92988 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1154,6 +1154,9 @@ static bool addRecordToPacket(DNSPacketWriter& pw, const DNSRecord& rec, uint32_ class RunningResolveGuard { public: RunningResolveGuard(std::unique_ptr& 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& d_dc;