Fix shadowed variables reported by `-Wshadow`.
str<<"dnsdist."<<hostname<<".main."<<e.first<<' ';
if(const auto& val = boost::get<DNSDistStats::stat_t*>(&e.second))
str<<(*val)->load();
- else if (const auto& val = boost::get<double*>(&e.second))
- str<<**val;
+ else if (const auto& dval = boost::get<double*>(&e.second))
+ str<<**dval;
else
str<<(*boost::get<DNSDistStats::statfunction_t>(&e.second))(e.first);
str<<' '<<now<<"\r\n";
}
const auto states = g_dstates.getCopy();
- for(const auto& s : states) {
- string serverName = s->getName();
+ for(const auto& state : states) {
+ string serverName = state->getName();
boost::replace_all(serverName, ".", "_");
const string base = "dnsdist." + hostname + ".main.servers." + serverName + ".";
- str<<base<<"queries" << ' ' << s->queries.load() << " " << now << "\r\n";
- str<<base<<"drops" << ' ' << s->reuseds.load() << " " << now << "\r\n";
- str<<base<<"latency" << ' ' << (s->availability != DownstreamState::Availability::Down ? s->latencyUsec/1000.0 : 0) << " " << now << "\r\n";
- str<<base<<"senderrors" << ' ' << s->sendErrors.load() << " " << now << "\r\n";
- str<<base<<"outstanding" << ' ' << s->outstanding.load() << " " << now << "\r\n";
+ str<<base<<"queries" << ' ' << state->queries.load() << " " << now << "\r\n";
+ str<<base<<"drops" << ' ' << state->reuseds.load() << " " << now << "\r\n";
+ str<<base<<"latency" << ' ' << (state->availability != DownstreamState::Availability::Down ? state->latencyUsec/1000.0 : 0) << " " << now << "\r\n";
+ str<<base<<"senderrors" << ' ' << state->sendErrors.load() << " " << now << "\r\n";
+ str<<base<<"outstanding" << ' ' << state->outstanding.load() << " " << now << "\r\n";
}
for(const auto& front : g_frontends) {
if (front->udpFD == -1 && front->tcpFD == -1)
>
>(withReturn ? ("return "+line) : line);
if(ret) {
- if (const auto strValue = boost::get<shared_ptr<DownstreamState>>(&*ret)) {
- cout<<(*strValue)->getName()<<endl;
+ if (const auto dsValue = boost::get<shared_ptr<DownstreamState>>(&*ret)) {
+ cout<<(*dsValue)->getName()<<endl;
}
else if (const auto strValue = boost::get<string>(&*ret)) {
cout<<*strValue<<endl;
std::rethrow_if_nested(e);
std::cerr << std::endl;
- } catch(const std::exception& e) {
- // e is the exception that was thrown from inside the lambda
- std::cerr << ": " << e.what() << std::endl;
+ } catch(const std::exception& ne) {
+ // ne is the exception that was thrown from inside the lambda
+ std::cerr << ": " << ne.what() << std::endl;
}
- catch(const PDNSException& e) {
- // e is the exception that was thrown from inside the lambda
- std::cerr << ": " << e.reason << std::endl;
+ catch(const PDNSException& ne) {
+ // ne is the exception that was thrown from inside the lambda
+ std::cerr << ": " << ne.reason << std::endl;
}
}
catch(const std::exception& e) {
- // e is the exception that was thrown from inside the lambda
std::cerr << e.what() << std::endl;
}
}
>(withReturn ? ("return "+line) : line);
if(ret) {
- if (const auto strValue = boost::get<shared_ptr<DownstreamState>>(&*ret)) {
- response=(*strValue)->getName()+"\n";
+ if (const auto dsValue = boost::get<shared_ptr<DownstreamState>>(&*ret)) {
+ response=(*dsValue)->getName()+"\n";
}
else if (const auto strValue = boost::get<string>(&*ret)) {
response=*strValue+"\n";
response = "Error: " + string(e.what());
try {
std::rethrow_if_nested(e);
- } catch(const std::exception& e) {
- // e is the exception that was thrown from inside the lambda
- response+= ": " + string(e.what());
+ } catch(const std::exception& ne) {
+ // ne is the exception that was thrown from inside the lambda
+ response+= ": " + string(ne.what());
}
- catch(const PDNSException& e) {
- // e is the exception that was thrown from inside the lambda
- response += ": " + string(e.reason);
+ catch(const PDNSException& ne) {
+ // ne is the exception that was thrown from inside the lambda
+ response += ": " + string(ne.reason);
}
}
catch(const LuaContext::SyntaxErrorException& e) {
}
if(vars.count("qps")) {
- int qps=std::stoi(boost::get<string>(vars["qps"]));
- ret->qps=QPSLimiter(qps, qps);
+ int qpsVal=std::stoi(boost::get<string>(vars["qps"]));
+ ret->qps=QPSLimiter(qpsVal, qpsVal);
}
auto localPools = g_pools.getCopy();
string second;
if(const auto& val = boost::get<DNSDistStats::stat_t*>(&e.second))
second=std::to_string((*val)->load());
- else if (const auto& val = boost::get<double*>(&e.second))
- second=(flt % (**val)).str();
+ else if (const auto& dval = boost::get<double*>(&e.second))
+ second=(flt % (**dval)).str();
else
second=std::to_string((*boost::get<DNSDistStats::statfunction_t>(&e.second))(e.first));
}
StatNode::Stat node;
- root.visit([&visitor](const StatNode* node, const StatNode::Stat& self, const StatNode::Stat& children) {
- visitor(*node, self, children);}, node);
+ root.visit([&visitor](const StatNode* node_, const StatNode::Stat& self, const StatNode::Stat& children) {
+ visitor(*node_, self, children);}, node);
}
for(const auto& e : g_stats.entries) {
if(const auto& val = boost::get<DNSDistStats::stat_t*>(&e.second))
obj.insert({e.first, (double)(*val)->load()});
- else if (const auto& val = boost::get<double*>(&e.second))
- obj.insert({e.first, (**val)});
+ else if (const auto& dval = boost::get<double*>(&e.second))
+ obj.insert({e.first, (**dval)});
else
obj.insert({e.first, (int)(*boost::get<DNSDistStats::statfunction_t>(&e.second))(e.first)});
}
{ "value", (double)(*val)->load() }
});
}
- else if (const auto& val = boost::get<double*>(&item.second)) {
+ else if (const auto& dval = boost::get<double*>(&item.second)) {
doc.push_back(Json::object {
{ "type", "StatisticItem" },
{ "name", item.first },
- { "value", (**val) }
+ { "value", (**dval) }
});
}
else {
{ "verbose-health-checks", g_verboseHealthChecks }
};
for(const auto& item : configEntries) {
- if (const auto& val = boost::get<bool>(&item.second)) {
+ if (const auto& bval = boost::get<bool>(&item.second)) {
doc.push_back(Json::object {
{ "type", "ConfigSetting" },
{ "name", item.first },
- { "value", *val }
+ { "value", *bval }
});
}
- else if (const auto& val = boost::get<string>(&item.second)) {
+ else if (const auto& sval = boost::get<string>(&item.second)) {
doc.push_back(Json::object {
{ "type", "ConfigSetting" },
{ "name", item.first },
- { "value", *val }
+ { "value", *sval }
});
}
- else if (const auto& val = boost::get<double>(&item.second)) {
+ else if (const auto& dval = boost::get<double>(&item.second)) {
doc.push_back(Json::object {
{ "type", "ConfigSetting" },
{ "name", item.first },
- { "value", *val }
+ { "value", *dval }
});
}
}
return shared_ptr<DownstreamState>();
int r = val % sum;
- auto p = upper_bound(poss.begin(), poss.end(),r, [](int r, const decltype(poss)::value_type& a) { return r < a.first;});
+ auto p = upper_bound(poss.begin(), poss.end(),r, [](int r_, const decltype(poss)::value_type& a) { return r_ < a.first;});
if(p==poss.end())
return shared_ptr<DownstreamState>();
return p->second;
});
/* and now we need to renumber for Lua (custom policies) */
size_t idx = 1;
- for (auto& server : pool->servers) {
- server.first = idx++;
+ for (auto& serv : pool->servers) {
+ serv.first = idx++;
}
}
template<typename T>
struct SuffixMatchTree
{
- SuffixMatchTree(const std::string& name_="", bool endNode_=false) : name(name_), endNode(endNode_)
+ SuffixMatchTree(const std::string& name="", bool endNode_=false) : d_name(name), endNode(endNode_)
{}
SuffixMatchTree(const SuffixMatchTree& rhs)
{
- name = rhs.name;
+ d_name = rhs.d_name;
children = rhs.children;
endNode = rhs.endNode;
d_value = rhs.d_value;
}
- std::string name;
+ std::string d_name;
mutable std::set<SuffixMatchTree> children;
mutable bool endNode;
mutable T d_value;
bool operator<(const SuffixMatchTree& rhs) const
{
- return strcasecmp(name.c_str(), rhs.name.c_str()) < 0;
+ return strcasecmp(d_name.c_str(), rhs.d_name.c_str()) < 0;
}
typedef SuffixMatchTree value_type;
static DNSDistPacketCache PC(500000);
-static void *threadMangler(void* a)
+static void *threadMangler(void* off)
{
try {
ComboAddress remote;
- unsigned int offset=(unsigned int)(unsigned long)a;
+ unsigned int offset=(unsigned int)(unsigned long)off;
for(unsigned int counter=0; counter < 100000; ++counter) {
DNSName a=DNSName("hello ")+DNSName(std::to_string(counter+offset));
vector<uint8_t> query;
AtomicCounter g_missing;
-static void *threadReader(void* a)
+static void *threadReader(void* off)
{
try
{
- unsigned int offset=(unsigned int)(unsigned long)a;
+ unsigned int offset=(unsigned int)(unsigned long)off;
vector<DNSResourceRecord> entry;
ComboAddress remote;
for(unsigned int counter=0; counter < 100000; ++counter) {