From: Otto Moerbeek Date: Tue, 15 Sep 2020 11:23:51 +0000 (+0200) Subject: Reformat X-Git-Tag: rec-4.5.0-alpha0^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f1b8e7945b2e018543aaa94f570424192a6eb65;p=thirdparty%2Fpdns.git Reformat --- diff --git a/pdns/recursordist/negcache.cc b/pdns/recursordist/negcache.cc index 5897ffb725..3f4c13a130 100644 --- a/pdns/recursordist/negcache.cc +++ b/pdns/recursordist/negcache.cc @@ -26,7 +26,8 @@ #include "cachecleaner.hh" #include "utility.hh" -NegCache::NegCache(size_t mapsCount) : d_maps(mapsCount) +NegCache::NegCache(size_t mapsCount) : + d_maps(mapsCount) { } @@ -39,7 +40,7 @@ NegCache::~NegCache() locks.push_back(lock_t(new lock(map))); } } - catch(...) { + catch (...) { } } diff --git a/pdns/recursordist/negcache.hh b/pdns/recursordist/negcache.hh index 894d07501b..d27432426e 100644 --- a/pdns/recursordist/negcache.hh +++ b/pdns/recursordist/negcache.hh @@ -49,7 +49,6 @@ typedef struct class NegCache : public boost::noncopyable { public: - NegCache(size_t mapsCount = 1024); ~NegCache(); @@ -109,8 +108,8 @@ private: struct MapCombo { MapCombo() {} - MapCombo(const MapCombo &) = delete; - MapCombo & operator=(const MapCombo &) = delete; + MapCombo(const MapCombo&) = delete; + MapCombo& operator=(const MapCombo&) = delete; negcache_t d_map; mutable std::mutex mutex; std::atomic d_entriesCount{0}; @@ -121,17 +120,20 @@ private: vector d_maps; - MapCombo& getMap(const DNSName &qname) + MapCombo& getMap(const DNSName& qname) { return d_maps[qname.hash() % d_maps.size()]; } - const MapCombo& getMap(const DNSName &qname) const + const MapCombo& getMap(const DNSName& qname) const { return d_maps[qname.hash() % d_maps.size()]; } + public: - struct lock { - lock(const MapCombo& map) : m(map.mutex) + struct lock + { + lock(const MapCombo& map) : + m(map.mutex) { if (!m.try_lock()) { m.lock(); @@ -139,11 +141,12 @@ public: } map.d_acquired_count++; } - ~lock() { + ~lock() + { m.unlock(); } + private: - std::mutex &m; + std::mutex& m; }; - };