From cdcf7eeb38b5274ca8ad300b6338f37f528e329a Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Thu, 29 Mar 2018 11:36:13 +0200 Subject: [PATCH] dnsdist: Be consistent about the shards's unique_ptr constness --- pdns/dnsdist-lua-inspection.cc | 22 +++++++++++----------- pdns/dnsdist-rings.cc | 4 ++-- pdns/dnsdistdist/test-dnsdistrings_cc.cc | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pdns/dnsdist-lua-inspection.cc b/pdns/dnsdist-lua-inspection.cc index c7afa0fc0..f8829d88f 100644 --- a/pdns/dnsdist-lua-inspection.cc +++ b/pdns/dnsdist-lua-inspection.cc @@ -32,7 +32,7 @@ static std::unordered_map>> g map counts; unsigned int total=0; { - for (auto& shard : g_rings.d_shards) { + for (const auto& shard : g_rings.d_shards) { std::lock_guard rl(shard->respLock); if(!labels) { for(const auto& a : shard->respRing) { @@ -106,7 +106,7 @@ static void statNodeRespRing(statvisitor_t visitor, unsigned int seconds) cutoff.tv_sec -= seconds; StatNode root; - for (auto& shard : g_rings.d_shards) { + for (const auto& shard : g_rings.d_shards) { std::lock_guard rl(shard->respLock); for(const auto& c : shard->respRing) { @@ -130,7 +130,7 @@ static vector > > getRespRi typedef std::unordered_map entry_t; vector > ret; - for (auto& shard : g_rings.d_shards) { + for (const auto& shard : g_rings.d_shards) { std::lock_guard rl(shard->respLock); entry_t e; @@ -158,7 +158,7 @@ static counts_t exceedRespGen(unsigned int rate, int seconds, std::function rl(shard->respLock); for(const auto& c : shard->respRing) { @@ -187,7 +187,7 @@ static counts_t exceedQueryGen(unsigned int rate, int seconds, std::function rl(shard->queryLock); for(const auto& c : shard->queryRing) { if(seconds && c.when < cutoff) @@ -230,7 +230,7 @@ void setupLuaInspection() map counts; unsigned int total=0; { - for (auto& shard : g_rings.d_shards) { + for (const auto& shard : g_rings.d_shards) { std::lock_guard rl(shard->queryLock); for(const auto& c : shard->queryRing) { counts[c.requestor]++; @@ -263,7 +263,7 @@ void setupLuaInspection() map counts; unsigned int total=0; if(!labels) { - for (auto& shard : g_rings.d_shards) { + for (const auto& shard : g_rings.d_shards) { std::lock_guard rl(shard->queryLock); for(const auto& a : shard->queryRing) { counts[a.name]++; @@ -273,7 +273,7 @@ void setupLuaInspection() } else { unsigned int lab = *labels; - for (auto& shard : g_rings.d_shards) { + for (const auto& shard : g_rings.d_shards) { std::lock_guard rl(shard->queryLock); for(auto a : shard->queryRing) { a.name.trimToLabels(lab); @@ -313,7 +313,7 @@ void setupLuaInspection() size_t totalEntries = 0; std::vector> rings; rings.reserve(g_rings.getNumberOfShards()); - for (auto& shard : g_rings.d_shards) { + for (const auto& shard : g_rings.d_shards) { { std::lock_guard rl(shard->respLock); rings.push_back(shard->respRing); @@ -409,7 +409,7 @@ void setupLuaInspection() std::vector rr; qr.reserve(g_rings.getNumberOfQueryEntries()); rr.reserve(g_rings.getNumberOfResponseEntries()); - for (auto& shard : g_rings.d_shards) { + for (const auto& shard : g_rings.d_shards) { { std::lock_guard rl(shard->queryLock); for (const auto& entry : shard->queryRing) { @@ -503,7 +503,7 @@ void setupLuaInspection() double totlat=0; unsigned int size=0; { - for (auto& shard : g_rings.d_shards) { + for (const auto& shard : g_rings.d_shards) { std::lock_guard rl(shard->respLock); for(const auto& r : shard->respRing) { /* skip actively discovered timeouts */ diff --git a/pdns/dnsdist-rings.cc b/pdns/dnsdist-rings.cc index c1155653c..c7cb57d22 100644 --- a/pdns/dnsdist-rings.cc +++ b/pdns/dnsdist-rings.cc @@ -25,7 +25,7 @@ size_t Rings::numDistinctRequestors() { std::set s; - for (auto& shard : d_shards) { + for (const auto& shard : d_shards) { std::lock_guard rl(shard->queryLock); for(const auto& q : shard->queryRing) { s.insert(q.requestor); @@ -38,7 +38,7 @@ std::unordered_map>> Rings::getTopBand { map counts; uint64_t total=0; - for (auto& shard : d_shards) { + for (const auto& shard : d_shards) { { std::lock_guard rl(shard->queryLock); for(const auto& q : shard->queryRing) { diff --git a/pdns/dnsdistdist/test-dnsdistrings_cc.cc b/pdns/dnsdistdist/test-dnsdistrings_cc.cc index 63ec03211..7849b51f5 100644 --- a/pdns/dnsdistdist/test-dnsdistrings_cc.cc +++ b/pdns/dnsdistdist/test-dnsdistrings_cc.cc @@ -127,7 +127,7 @@ static void ringReaderThread(Rings& rings, std::atomic& done, size_t numbe size_t numberOfQueries = 0; size_t numberOfResponses = 0; - for (auto& shard : rings.d_shards) { + for (const auto& shard : rings.d_shards) { { std::lock_guard rl(shard->queryLock); for(const auto& c : shard->queryRing) { -- 2.40.0