From: Chris Hofstaedtler Date: Mon, 15 Mar 2021 09:05:27 +0000 (+0100) Subject: Reformat X-Git-Tag: auth-4.5.0-alpha1~7^2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58eb774e207c193cec08a0ab4ecba540f4cdee6b;p=thirdparty%2Fpdns.git Reformat --- diff --git a/modules/bindbackend/bindbackend2.cc b/modules/bindbackend/bindbackend2.cc index 0010a2a9b2..750125276f 100644 --- a/modules/bindbackend/bindbackend2.cc +++ b/modules/bindbackend/bindbackend2.cc @@ -704,7 +704,7 @@ string Bind2Backend::DLAddDomainHandler(const vector& parts, Utility::pi safePutBBDomainInfo(bbd); - g_domainCache.add(domainname, bbd.d_id); // make new domain visible + g_domainCache.add(domainname, bbd.d_id); // make new domain visible g_log << Logger::Warning << "Zone " << domainname << " loaded" << endl; return "Loaded zone " + domainname.toLogString() + " from " + filename; diff --git a/pdns/auth-domaincache.cc b/pdns/auth-domaincache.cc index 65b9839a9d..c23ce7a1ee 100644 --- a/pdns/auth-domaincache.cc +++ b/pdns/auth-domaincache.cc @@ -30,15 +30,16 @@ #include "cachecleaner.hh" extern StatBag S; -AuthDomainCache::AuthDomainCache(size_t mapsCount): d_maps(mapsCount) +AuthDomainCache::AuthDomainCache(size_t mapsCount) : + d_maps(mapsCount) { S.declare("domain-cache-hit", "Number of hits on the domain cache"); S.declare("domain-cache-miss", "Number of misses on the domain cache"); S.declare("domain-cache-size", "Number of entries in the domain cache", StatType::gauge); - d_statnumhit=S.getPointer("domain-cache-hit"); - d_statnummiss=S.getPointer("domain-cache-miss"); - d_statnumentries=S.getPointer("domain-cache-size"); + d_statnumhit = S.getPointer("domain-cache-hit"); + d_statnummiss = S.getPointer("domain-cache-miss"); + d_statnumentries = S.getPointer("domain-cache-size"); d_ttl = 0; } @@ -47,16 +48,16 @@ AuthDomainCache::~AuthDomainCache() { try { vector locks; - for(auto& mc : d_maps) { + for (auto& mc : d_maps) { locks.push_back(WriteLock(mc.d_mut)); } locks.clear(); } - catch(...) { + catch (...) { } } -bool AuthDomainCache::getEntry(const DNSName &domain, int& zoneId) +bool AuthDomainCache::getEntry(const DNSName& domain, int& zoneId) { auto& mc = getMap(domain); bool found = false; @@ -71,7 +72,8 @@ bool AuthDomainCache::getEntry(const DNSName &domain, int& zoneId) if (found) { (*d_statnumhit)++; - } else { + } + else { (*d_statnummiss)++; } return found; @@ -87,16 +89,16 @@ void AuthDomainCache::clear() purgeLockedCollectionsVector(d_maps); } -void AuthDomainCache::replace(const vector> &domain_indices) +void AuthDomainCache::replace(const vector>& domain_indices) { - if(!d_ttl) + if (!d_ttl) return; size_t count = domain_indices.size(); vector newMaps(d_maps.size()); // build new maps - for(const tuple& tup: domain_indices) { + for (const tuple& tup : domain_indices) { const DNSName& domain = tup.get<0>(); CacheValue val; val.zoneId = tup.get<1>(); @@ -104,8 +106,7 @@ void AuthDomainCache::replace(const vector> &domain_indices) mc.d_map.emplace(domain, val); } - for(size_t mapIndex = 0; mapIndex < d_maps.size(); mapIndex++) - { + for (size_t mapIndex = 0; mapIndex < d_maps.size(); mapIndex++) { auto& mc = d_maps[mapIndex]; WriteLock l(mc.d_mut); mc.d_map = std::move(newMaps[mapIndex].d_map); @@ -116,7 +117,7 @@ void AuthDomainCache::replace(const vector> &domain_indices) void AuthDomainCache::add(const DNSName& domain, const int zoneId) { - if(!d_ttl) + if (!d_ttl) return; CacheValue val; diff --git a/pdns/auth-domaincache.hh b/pdns/auth-domaincache.hh index 7bdfd188bd..162d98f511 100644 --- a/pdns/auth-domaincache.hh +++ b/pdns/auth-domaincache.hh @@ -28,21 +28,23 @@ class AuthDomainCache : public boost::noncopyable { public: - AuthDomainCache(size_t mapsCount=1024); + AuthDomainCache(size_t mapsCount = 1024); ~AuthDomainCache(); - void replace(const vector> &domains); + void replace(const vector>& domains); void add(const DNSName& domain, const int zoneId); - bool getEntry(const DNSName &domain, int &zoneId); + bool getEntry(const DNSName& domain, int& zoneId); size_t size() { return *d_statnumentries; } //!< number of entries in the cache - uint32_t getTTL() const { + uint32_t getTTL() const + { return d_ttl; } - void setTTL(uint32_t ttl) { + void setTTL(uint32_t ttl) + { d_ttl = ttl; } @@ -60,10 +62,10 @@ private: struct MapCombo { - MapCombo() { } - ~MapCombo() { } - MapCombo(const MapCombo &) = delete; - MapCombo & operator=(const MapCombo &) = delete; + MapCombo() {} + ~MapCombo() {} + MapCombo(const MapCombo&) = delete; + MapCombo& operator=(const MapCombo&) = delete; ReadWriteLock d_mut; cmap_t d_map; @@ -79,9 +81,9 @@ private: return d_maps[getMapIndex(qname)]; } - AtomicCounter *d_statnumhit; - AtomicCounter *d_statnummiss; - AtomicCounter *d_statnumentries; + AtomicCounter* d_statnumhit; + AtomicCounter* d_statnummiss; + AtomicCounter* d_statnumentries; time_t d_ttl{0}; };