]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: a bit of tidy
authorCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Mon, 18 Dec 2023 13:53:04 +0000 (14:53 +0100)
committerCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Thu, 18 Jan 2024 17:12:00 +0000 (18:12 +0100)
pdns/communicator.cc
pdns/communicator.hh

index 8834e3a667ca2dc22615763d0cd7b293e1dccd7d..1de71defdb564cb8fdff25676aafd3920f14d1bd 100644 (file)
@@ -93,7 +93,7 @@ void CommunicatorClass::go()
   std::thread mainT([this]() { mainloop(); });
   mainT.detach();
 
-  for (int n = 0; n < ::arg().asNum("retrieval-threads", 1); ++n) {
+  for (int nthreads = 0; nthreads < ::arg().asNum("retrieval-threads", 1); ++nthreads) {
     std::thread retrieve([this]() { retrievalLoopThread(); });
     retrieve.detach();
   }
@@ -143,7 +143,7 @@ void CommunicatorClass::mainloop()
       while (time(nullptr) < next) {
         rc = d_any_sem.tryWait();
 
-        if (rc) {
+        if (rc != 0) {
           bool extraSecondaryRefresh = false;
           Utility::sleep(1);
           {
index 3e06d5359d9f60f42fea2a58a9f4e77e8b4d3a1f..032117c672ae7c17fe46cf62e69e747afe385f3c 100644 (file)
@@ -65,24 +65,23 @@ struct IDTag
 {
 };
 
-typedef multi_index_container<
+using UniQueue = multi_index_container<
   SuckRequest,
   indexed_by<
     ordered_unique<member<SuckRequest, std::pair<SuckRequest::RequestPriority, uint64_t>, &SuckRequest::priorityAndOrder>>,
-    ordered_unique<tag<IDTag>, identity<SuckRequest>>>>
-  UniQueue;
-typedef UniQueue::index<IDTag>::type domains_by_name_t;
+    ordered_unique<tag<IDTag>, identity<SuckRequest>>>>;
+using domains_by_name_t = UniQueue::index<IDTag>::type;
 
 class NotificationQueue
 {
 public:
-  void add(const DNSName& domain, const string& ip, time_t delay = 0)
+  void add(const DNSName& domain, const string& ipstring, time_t delay = 0)
   {
-    const ComboAddress caIp(ip);
+    const ComboAddress ipaddress(ipstring);
 
     NotificationRequest nr;
     nr.domain = domain;
-    nr.ip = caIp.toStringWithPort();
+    nr.ip = ipaddress.toStringWithPort();
     nr.attempts = 0;
     nr.id = dns_random_uint16();
     nr.next = time(nullptr) + delay;
@@ -105,10 +104,10 @@ public:
   bool getOne(DNSName& domain, string& ip, uint16_t* id, bool& purged)
   {
     for (d_nqueue_t::iterator i = d_nqueue.begin(); i != d_nqueue.end(); ++i)
-      if (i->next <= time(0)) {
+      if (i->next <= time(nullptr)) {
         i->attempts++;
         purged = false;
-        i->next = time(0) + 1 + (1 << i->attempts);
+        i->next = time(nullptr) + 1 + (1 << i->attempts);
         domain = i->domain;
         ip = i->ip;
         *id = i->id;
@@ -127,7 +126,7 @@ public:
     time_t early = std::numeric_limits<time_t>::max() - 1;
     for (d_nqueue_t::const_iterator i = d_nqueue.begin(); i != d_nqueue.end(); ++i)
       early = min(early, i->next);
-    return early - time(0);
+    return early - time(nullptr);
   }
 
   void dump();
@@ -142,7 +141,7 @@ private:
     uint16_t id;
   };
 
-  typedef std::list<NotificationRequest> d_nqueue_t;
+  using d_nqueue_t = std::list<NotificationRequest>;
   d_nqueue_t d_nqueue;
 };
 
@@ -179,7 +178,7 @@ public:
   size_t getSuckRequestsWaiting();
 
 private:
-  void loadArgsIntoSet(const char* listname, set<string>& listset);
+  static void loadArgsIntoSet(const char* listname, set<string>& listset);
   void makeNotifySockets();
   void queueNotifyDomain(const DomainInfo& di, UeberBackend* B);
   int d_nsock4, d_nsock6;