]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
chore(dnsdist): Send delayed protobuf through RAII
authorPieter Lexis <pieter.lexis@powerdns.com>
Tue, 25 Nov 2025 09:49:10 +0000 (10:49 +0100)
committerPieter Lexis <pieter.lexis@powerdns.com>
Fri, 12 Dec 2025 15:30:51 +0000 (16:30 +0100)
pdns/dnsdistdist/dnsdist-idstate.cc
pdns/dnsdistdist/dnsdist-idstate.hh
pdns/dnsdistdist/dnsdist.cc

index 7e80710a715d74f93e8c20160797dcdde5b8e53a..efb2c0af37a8ac54207acffe8d25d1a7e2a514dc 100644 (file)
@@ -60,12 +60,12 @@ InternalQueryState InternalQueryState::partialCloneForXFR() const
   return ids;
 }
 
-void InternalQueryState::sendDelayedProtobufMessages() const
+InternalQueryState::~InternalQueryState()
 {
 #ifndef DISABLE_PROTOBUF
   static thread_local string otPBBuf;
   otPBBuf.clear();
-  if (tracingEnabled) {
+  if (tracingEnabled && d_OTTracer != nullptr) {
     pdns::ProtoZero::Message msg{otPBBuf};
     msg.setOpenTelemetryData(d_OTTracer->getOTProtobuf());
   }
index cb2b2be4ba3f34fa3241a13383ed84a2061eccdf..7259f96f6a0da09965cc497a40aa4678cee61ef4 100644 (file)
@@ -163,6 +163,7 @@ struct InternalQueryState
 
   InternalQueryState(const InternalQueryState& orig) = delete;
   InternalQueryState& operator=(const InternalQueryState& orig) = delete;
+  ~InternalQueryState();
 
   bool isXSK() const noexcept
   {
@@ -173,8 +174,6 @@ struct InternalQueryState
 #endif /* HAVE_XSK */
   }
 
-  void sendDelayedProtobufMessages() const;
-
   InternalQueryState partialCloneForXFR() const;
 
   std::optional<Netmask> subnet{std::nullopt}; // 40
index 4e85d911b029b1cd560e95b04932f6a8ab3873f2..877db4f2ade7e927d1825e1568c1b33e9de30541 100644 (file)
@@ -642,7 +642,6 @@ bool sendUDPResponse(int origFD, const PacketBuffer& response, [[maybe_unused]]
 void handleResponseSent(const InternalQueryState& ids, double udiff, const ComboAddress& client, const ComboAddress& backend, unsigned int size, const dnsheader& cleartextDH, dnsdist::Protocol outgoingProtocol, bool fromBackend)
 {
   handleResponseSent(ids.qname, ids.qtype, udiff, client, backend, size, cleartextDH, outgoingProtocol, ids.protocol, fromBackend);
-  ids.sendDelayedProtobufMessages();
 }
 
 void handleResponseSent(const DNSName& qname, const QType& qtype, double udiff, const ComboAddress& client, const ComboAddress& backend, unsigned int size, const dnsheader& cleartextDH, dnsdist::Protocol outgoingProtocol, dnsdist::Protocol incomingProtocol, bool fromBackend)