From: Otto Moerbeek Date: Mon, 2 Dec 2019 15:06:33 +0000 (+0100) Subject: Avoid copying of pthread_rwlock_t X-Git-Tag: auth-4.3.0-alpha1~6^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F8601%2Fhead;p=thirdparty%2Fpdns.git Avoid copying of pthread_rwlock_t --- diff --git a/pdns/auth-packetcache.cc b/pdns/auth-packetcache.cc index 8389c17963..c38599dece 100644 --- a/pdns/auth-packetcache.cc +++ b/pdns/auth-packetcache.cc @@ -30,10 +30,8 @@ extern StatBag S; const unsigned int AuthPacketCache::s_mincleaninterval, AuthPacketCache::s_maxcleaninterval; -AuthPacketCache::AuthPacketCache(size_t mapsCount): d_lastclean(time(nullptr)) +AuthPacketCache::AuthPacketCache(size_t mapsCount): d_lastclean(time(nullptr)), d_maps(mapsCount) { - d_maps.resize(mapsCount); - S.declare("packetcache-hit", "Number of hits on the packet cache"); S.declare("packetcache-miss", "Number of misses on the packet cache"); S.declare("packetcache-size", "Number of entries in the packet cache"); diff --git a/pdns/auth-packetcache.hh b/pdns/auth-packetcache.hh index ba49128bf9..e0191dc950 100644 --- a/pdns/auth-packetcache.hh +++ b/pdns/auth-packetcache.hh @@ -110,6 +110,9 @@ private: ~MapCombo() { pthread_rwlock_destroy(&d_mut); } + MapCombo(const MapCombo&) = delete; + MapCombo& operator=(const MapCombo&) = delete; + pthread_rwlock_t d_mut; cmap_t d_map; }; diff --git a/pdns/auth-querycache.cc b/pdns/auth-querycache.cc index 0bc546e9bf..2dc8c3254b 100644 --- a/pdns/auth-querycache.cc +++ b/pdns/auth-querycache.cc @@ -31,10 +31,8 @@ extern StatBag S; const unsigned int AuthQueryCache::s_mincleaninterval, AuthQueryCache::s_maxcleaninterval; -AuthQueryCache::AuthQueryCache(size_t mapsCount): d_lastclean(time(nullptr)) +AuthQueryCache::AuthQueryCache(size_t mapsCount): d_maps(mapsCount), d_lastclean(time(nullptr)) { - d_maps.resize(mapsCount); - S.declare("query-cache-hit","Number of hits on the query cache"); S.declare("query-cache-miss","Number of misses on the query cache"); S.declare("query-cache-size", "Number of entries in the query cache"); diff --git a/pdns/auth-querycache.hh b/pdns/auth-querycache.hh index e48ad2dfb0..193f91bf92 100644 --- a/pdns/auth-querycache.hh +++ b/pdns/auth-querycache.hh @@ -93,6 +93,9 @@ private: ~MapCombo() { pthread_rwlock_destroy(&d_mut); } + MapCombo(const MapCombo &) = delete; + MapCombo & operator=(const MapCombo &) = delete; + pthread_rwlock_t d_mut; cmap_t d_map; };