"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pdns/statbag.cc" between
pdns-auth-4.1.13.tar.gz and pdns-auth-4.2.0.tar.gz

About: PowerDNS Authoritative Nameserver is a versatile nameserver which supports a large number of backends (that can either be plain zone files or be more dynamic in nature).

statbag.cc  (pdns-auth-4.1.13):statbag.cc  (pdns-auth-4.2.0)
skipping to change at line 55 skipping to change at line 55
{ {
throw PDNSException("Trying to deposit into unknown StatBag key '"+key+"'" ); throw PDNSException("Trying to deposit into unknown StatBag key '"+key+"'" );
} }
} }
string StatBag::directory() string StatBag::directory()
{ {
string dir; string dir;
ostringstream o; ostringstream o;
for(map<string, AtomicCounter *>::const_iterator i=d_stats.begin(); for(const auto& i: d_stats) {
i!=d_stats.end(); if (d_blacklist.find(i.first) != d_blacklist.end())
i++) continue;
{ o<<i.first<<"="<<*(i.second)<<",";
o<<i->first<<"="<<*(i->second)<<","; }
}
for(const funcstats_t::value_type& val : d_funcstats) { for(const funcstats_t::value_type& val : d_funcstats) {
if (d_blacklist.find(val.first) != d_blacklist.end())
continue;
o << val.first<<"="<<val.second(val.first)<<","; o << val.first<<"="<<val.second(val.first)<<",";
} }
dir=o.str(); dir=o.str();
return dir; return dir;
} }
vector<string>StatBag::getEntries() vector<string>StatBag::getEntries()
{ {
vector<string> ret; vector<string> ret;
for(map<string, AtomicCounter *>::const_iterator i=d_stats.begin(); for(const auto& i: d_stats) {
i!=d_stats.end(); if (d_blacklist.find(i.first) != d_blacklist.end())
i++) continue;
ret.push_back(i->first); ret.push_back(i.first);
}
for(const funcstats_t::value_type& val : d_funcstats) { for(const funcstats_t::value_type& val : d_funcstats) {
if (d_blacklist.find(val.first) != d_blacklist.end())
continue;
ret.push_back(val.first); ret.push_back(val.first);
} }
return ret; return ret;
} }
string StatBag::getDescrip(const string &item) string StatBag::getDescrip(const string &item)
{ {
exists(item); exists(item);
skipping to change at line 151 skipping to change at line 155
} }
AtomicCounter *StatBag::getPointer(const string &key) AtomicCounter *StatBag::getPointer(const string &key)
{ {
exists(key); exists(key);
return d_stats[key]; return d_stats[key];
} }
StatBag::~StatBag() StatBag::~StatBag()
{ {
for(map<string, AtomicCounter *>::const_iterator i=d_stats.begin(); for(const auto& i: d_stats) {
i!=d_stats.end(); delete i.second;
i++) }
{
delete i->second;
}
} }
template<typename T, typename Comp> template<typename T, typename Comp>
StatRing<T,Comp>::StatRing(unsigned int size) StatRing<T,Comp>::StatRing(unsigned int size)
{ {
d_items.set_capacity(size); d_items.set_capacity(size);
pthread_mutex_init(&d_lock, 0); pthread_mutex_init(&d_lock, 0);
} }
skipping to change at line 220 skipping to change at line 221
for(typename map<T, unsigned int>::const_iterator i=res.begin();i!=res.end();+ +i) for(typename map<T, unsigned int>::const_iterator i=res.begin();i!=res.end();+ +i)
tmp.push_back(*i); tmp.push_back(*i);
sort(tmp.begin(),tmp.end(),popisort); sort(tmp.begin(),tmp.end(),popisort);
return tmp; return tmp;
} }
void StatBag::declareRing(const string &name, const string &help, unsigned int s ize) void StatBag::declareRing(const string &name, const string &help, unsigned int s ize)
{ {
d_rings[name]=StatRing<string>(size); d_rings[name]=StatRing<string, CIStringCompare>(size);
d_rings[name].setHelp(help); d_rings[name].setHelp(help);
} }
void StatBag::declareComboRing(const string &name, const string &help, unsigned int size) void StatBag::declareComboRing(const string &name, const string &help, unsigned int size)
{ {
d_comborings[name]=StatRing<SComboAddress>(size); d_comborings[name]=StatRing<SComboAddress>(size);
d_comborings[name].setHelp(help); d_comborings[name].setHelp(help);
} }
void StatBag::declareDNSNameQTypeRing(const string &name, const string &help, un
signed int size)
{
d_dnsnameqtyperings[name] = StatRing<std::tuple<DNSName, QType> >(size);
d_dnsnameqtyperings[name].setHelp(help);
}
vector<pair<string, unsigned int> > StatBag::getRing(const string &name) vector<pair<string, unsigned int> > StatBag::getRing(const string &name)
{ {
if(d_rings.count(name)) if(d_rings.count(name)) {
return d_rings[name].get(); return d_rings[name].get();
else { }
vector<pair<string, unsigned int> > ret;
if (d_comborings.count(name)) {
typedef pair<SComboAddress, unsigned int> stor_t; typedef pair<SComboAddress, unsigned int> stor_t;
vector<stor_t> raw =d_comborings[name].get(); vector<stor_t> raw =d_comborings[name].get();
vector<pair<string, unsigned int> > ret;
for(const stor_t& stor : raw) { for(const stor_t& stor : raw) {
ret.push_back(make_pair(stor.first.ca.toString(), stor.second)); ret.push_back(make_pair(stor.first.ca.toString(), stor.second));
} }
return ret; } else if(d_dnsnameqtyperings.count(name)) {
auto raw = d_dnsnameqtyperings[name].get();
for (auto const &e : raw) {
ret.push_back(make_pair(std::get<0>(e.first).toLogString() + "/" + std::ge
t<1>(e.first).getName(), e.second));
}
} }
return ret;
} }
template<typename T, typename Comp> template<typename T, typename Comp>
void StatRing<T,Comp>::reset() void StatRing<T,Comp>::reset()
{ {
Lock l(&d_lock); Lock l(&d_lock);
d_items.clear(); d_items.clear();
} }
void StatBag::resetRing(const string &name) void StatBag::resetRing(const string &name)
{ {
if(d_rings.count(name)) if(d_rings.count(name))
d_rings[name].reset(); d_rings[name].reset();
else if(d_comborings.count(name))
d_comborings[name].reset(); d_comborings[name].reset();
if(d_dnsnameqtyperings.count(name))
d_dnsnameqtyperings[name].reset();
} }
void StatBag::resizeRing(const string &name, unsigned int newsize) void StatBag::resizeRing(const string &name, unsigned int newsize)
{ {
if(d_rings.count(name)) if(d_rings.count(name))
d_rings[name].resize(newsize); d_rings[name].resize(newsize);
else if(d_comborings.count(name))
d_comborings[name].resize(newsize); d_comborings[name].resize(newsize);
if(d_dnsnameqtyperings.count(name))
return d_dnsnameqtyperings[name].resize(newsize);
} }
unsigned int StatBag::getRingSize(const string &name) unsigned int StatBag::getRingSize(const string &name)
{ {
if(d_rings.count(name)) if(d_rings.count(name))
return d_rings[name].getSize(); return d_rings[name].getSize();
else if(d_comborings.count(name))
return d_comborings[name].getSize(); return d_comborings[name].getSize();
if(d_dnsnameqtyperings.count(name))
return d_dnsnameqtyperings[name].getSize();
return 0;
} }
string StatBag::getRingTitle(const string &name) string StatBag::getRingTitle(const string &name)
{ {
if(d_rings.count(name)) if(d_rings.count(name))
return d_rings[name].getHelp(); return d_rings[name].getHelp();
else if(d_comborings.count(name))
return d_comborings[name].getHelp(); return d_comborings[name].getHelp();
if(d_dnsnameqtyperings.count(name))
return d_dnsnameqtyperings[name].getHelp();
return "";
} }
vector<string>StatBag::listRings() vector<string>StatBag::listRings()
{ {
vector<string> ret; vector<string> ret;
for(map<string,StatRing<string> >::const_iterator i=d_rings.begin();i!=d_rings .end();++i) for(auto i=d_rings.begin();i!=d_rings.end();++i)
ret.push_back(i->first); ret.push_back(i->first);
for(map<string,StatRing<SComboAddress> >::const_iterator i=d_comborings.begin( );i!=d_comborings.end();++i) for(auto i=d_comborings.begin();i!=d_comborings.end();++i)
ret.push_back(i->first); ret.push_back(i->first);
for(const auto &i : d_dnsnameqtyperings)
ret.push_back(i.first);
return ret; return ret;
} }
bool StatBag::ringExists(const string &name) bool StatBag::ringExists(const string &name)
{ {
return d_rings.count(name) || d_comborings.count(name); return d_rings.count(name) || d_comborings.count(name) || d_dnsnameqtyperings.
count(name);
}
void StatBag::blacklist(const string& str) {
d_blacklist.insert(str);
} }
template class StatRing<std::string>; template class StatRing<std::string, CIStringCompare>;
template class StatRing<SComboAddress>; template class StatRing<SComboAddress>;
template class StatRing<std::tuple<DNSName, QType> >;
 End of changes. 26 change blocks. 
30 lines changed or deleted 62 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)