From: Charles-Henri Bruyand Date: Mon, 18 Dec 2023 13:53:04 +0000 (+0100) Subject: auth: a bit of tidy X-Git-Tag: dnsdist-1.9.0-rc1~30^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=937cd921f20337f9de4eb0665308ec1cff5bfb1e;p=thirdparty%2Fpdns.git auth: a bit of tidy --- diff --git a/pdns/communicator.cc b/pdns/communicator.cc index 8834e3a667..1de71defdb 100644 --- a/pdns/communicator.cc +++ b/pdns/communicator.cc @@ -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); { diff --git a/pdns/communicator.hh b/pdns/communicator.hh index 3e06d5359d..032117c672 100644 --- a/pdns/communicator.hh +++ b/pdns/communicator.hh @@ -65,24 +65,23 @@ struct IDTag { }; -typedef multi_index_container< +using UniQueue = multi_index_container< SuckRequest, indexed_by< ordered_unique, &SuckRequest::priorityAndOrder>>, - ordered_unique, identity>>> - UniQueue; -typedef UniQueue::index::type domains_by_name_t; + ordered_unique, identity>>>; +using domains_by_name_t = UniQueue::index::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::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 d_nqueue_t; + using d_nqueue_t = std::list; d_nqueue_t d_nqueue; }; @@ -179,7 +178,7 @@ public: size_t getSuckRequestsWaiting(); private: - void loadArgsIntoSet(const char* listname, set& listset); + static void loadArgsIntoSet(const char* listname, set& listset); void makeNotifySockets(); void queueNotifyDomain(const DomainInfo& di, UeberBackend* B); int d_nsock4, d_nsock6;