]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Cleanup
authorFred Morcos <fred.morcos@open-xchange.com>
Thu, 22 Sep 2022 15:16:54 +0000 (17:16 +0200)
committerFred Morcos <fred.morcos@open-xchange.com>
Mon, 26 Sep 2022 08:43:04 +0000 (10:43 +0200)
pdns/communicator.hh
pdns/mastercommunicator.cc

index c96795ee5afc4411c3f2a60f23f4d15abd0f687a..4ad92171820ae77c112dfb42593d2d2a7647347d 100644 (file)
@@ -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);
index ac7dfd8c39697dc0d12cf6f4155f8b1e22964c9a..7bbfd78d5f5048196bc2b0e6c26e90be305e7154 100644 (file)
@@ -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<int> 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();