From: Fred Morcos Date: Thu, 22 Sep 2022 15:16:54 +0000 (+0200) Subject: Cleanup X-Git-Tag: rec-4.9.0-alpha0~35^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bd6223db09f31c71d0fa5cd13f4e2f0025c05d25;p=thirdparty%2Fpdns.git Cleanup --- diff --git a/pdns/communicator.hh b/pdns/communicator.hh index c96795ee5a..4ad9217182 100644 --- a/pdns/communicator.hh +++ b/pdns/communicator.hh @@ -82,12 +82,12 @@ public: d_nqueue.push_back(nr); } - bool removeIf(const string& remote, uint16_t id, const DNSName& domain) + bool removeIf(const ComboAddress& remote, uint16_t id, const DNSName& domain) { ServiceTuple stRemote, stQueued; parseService(remote, stRemote); - for (d_nqueue_t::iterator i = d_nqueue.begin(); i != d_nqueue.end(); ++i) { + for (auto i = d_nqueue.begin(); i != d_nqueue.end(); ++i) { parseService(i->ip, stQueued); if (i->id == id && stQueued.host == stRemote.host && i->domain == domain) { d_nqueue.erase(i); diff --git a/pdns/mastercommunicator.cc b/pdns/mastercommunicator.cc index ac7dfd8c39..7bbfd78d5f 100644 --- a/pdns/mastercommunicator.cc +++ b/pdns/mastercommunicator.cc @@ -216,18 +216,17 @@ time_t CommunicatorClass::doNotifications(PacketHandler* P) { UeberBackend* B = P->getBackend(); ComboAddress from; - Utility::socklen_t fromlen; char buffer[1500]; int sock; - ssize_t size; set fds = {d_nsock4, d_nsock6}; // receive incoming notifications on the nonblocking socket and take them off the list while (waitForMultiData(fds, 0, 0, &sock) > 0) { - fromlen = sizeof(from); - size = recvfrom(sock, buffer, sizeof(buffer), 0, (struct sockaddr*)&from, &fromlen); - if (size < 0) + Utility::socklen_t fromlen = sizeof(from); + const auto size = recvfrom(sock, buffer, sizeof(buffer), 0, (struct sockaddr*)&from, &fromlen); + if (size < 0) { break; + } DNSPacket p(true); p.setRemote(&from); @@ -237,11 +236,13 @@ time_t CommunicatorClass::doNotifications(PacketHandler* P) continue; } - if (p.d.rcode) + if (p.d.rcode) { g_log << Logger::Warning << "Received unsuccessful notification report for '" << p.qdomain << "' from " << from.toStringWithPort() << ", error: " << RCode::to_s(p.d.rcode) << endl; + } - if (d_nq.removeIf(from.toStringWithPort(), p.d.id, p.qdomain)) + if (d_nq.removeIf(from.toStringWithPort(), p.d.id, p.qdomain)) { g_log << Logger::Notice << "Removed from notification list: '" << p.qdomain << "' to " << from.toStringWithPort() << " " << (p.d.rcode ? RCode::to_s(p.d.rcode) : "(was acknowledged)") << endl; + } else { g_log << Logger::Warning << "Received spurious notify answer for '" << p.qdomain << "' from " << from.toStringWithPort() << endl; // d_nq.dump(); @@ -263,8 +264,9 @@ time_t CommunicatorClass::doNotifications(PacketHandler* P) d_nq.removeIf(remote.toStringWithPort(), id, domain); // Remove, we'll never be able to notify continue; // don't try to notify what we can't! } - if (d_preventSelfNotification && AddressIsUs(remote)) + if (d_preventSelfNotification && AddressIsUs(remote)) { continue; + } sendNotification(remote.sin4.sin_family == AF_INET ? d_nsock4 : d_nsock6, domain, remote, id, B); drillHole(domain, ip); @@ -273,8 +275,9 @@ time_t CommunicatorClass::doNotifications(PacketHandler* P) g_log << Logger::Warning << "Error trying to resolve '" << ip << "' for notifying '" << domain << "' to server: " << re.reason << endl; } } - else + else { g_log << Logger::Warning << "Notification for " << domain << " to " << ip << " failed after retries" << endl; + } } return d_nq.earliest();