From: Miod Vallat Date: Thu, 9 Jul 2026 14:05:26 +0000 (+0200) Subject: Only update network statistics if we could actually send the packets. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c83c3fa134cd86bab1f40614c0645ab5ccddb722;p=thirdparty%2Fpdns.git Only update network statistics if we could actually send the packets. Fixes: #15101 Signed-off-by: Miod Vallat --- diff --git a/pdns/nameserver.cc b/pdns/nameserver.cc index 5c06c4060b..649993cc27 100644 --- a/pdns/nameserver.cc +++ b/pdns/nameserver.cc @@ -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<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) diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc index 53c5faf1d7..fa0b0289bd 100644 --- a/pdns/tcpreceiver.cc +++ b/pdns/tcpreceiver.cc @@ -180,12 +180,11 @@ void TCPNameserver::sendPacket(std::unique_ptr& 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); }