]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Only update network statistics if we could actually send the packets.
authorMiod Vallat <miod.vallat@powerdns.com>
Thu, 9 Jul 2026 14:05:26 +0000 (16:05 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Thu, 9 Jul 2026 14:05:26 +0000 (16:05 +0200)
Fixes: #15101
Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
pdns/nameserver.cc
pdns/tcpreceiver.cc

index 5c06c4060b97e097e06458c2917728f58668670e..649993cc27ec29e9a88c34e572f5d7f61f68d4a5 100644 (file)
@@ -226,7 +226,6 @@ UDPNameserver::UDPNameserver(Logr::log_t slog, bool additional_socket)
 void UDPNameserver::send(DNSPacket& p)
 {
   const string& buffer=p.getString();
-  g_rs.submitResponse(p, true);
 
   struct msghdr msgh;
   struct iovec iov;
@@ -249,6 +248,8 @@ void UDPNameserver::send(DNSPacket& p)
     SLOG(g_log<<Logger::Error<<"Error sending reply with sendmsg (socket="<<p.getSocket()<<", dest="<<p.d_remote.toStringWithPort()<<"): "<<stringerror(err)<<endl,
          d_slog->error(Logr::Error, errno, "Error sending reply with sendmsg", "socket", Logging::Loggable(p.getSocket()), "remote", Logging::Loggable(p.d_remote.toStringWithPort())));
   }
+
+  g_rs.submitResponse(p, true);
 }
 
 bool UDPNameserver::receive(DNSPacket& packet, std::string& buffer)
index 53c5faf1d7f9f07dc422d2d16857285e42e75704..fa0b0289bd18071127706f42e1e7803f59f74b11 100644 (file)
@@ -180,12 +180,11 @@ void TCPNameserver::sendPacket(std::unique_ptr<DNSPacket>& p, int outsock, bool
 {
   uint16_t len=htons(p->getString(true).length());
 
-  // this also calls p->getString; call it after our explicit call so throwsOnTruncation=true is honoured
-  g_rs.submitResponse(*p, false, last);
-
   string buffer((const char*)&len, 2);
   buffer.append(p->getString());
   writenWithTimeout(outsock, buffer.c_str(), buffer.length(), d_idleTimeout);
+
+  g_rs.submitResponse(*p, false, last);
 }