From: Otto Moerbeek Date: Tue, 11 Jun 2019 06:56:03 +0000 (+0200) Subject: Maintain blacklist inside StatBag. X-Git-Tag: auth-4.2.0-rc2^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F7887%2Fhead;p=thirdparty%2Fpdns.git Maintain blacklist inside StatBag. --- diff --git a/pdns/dynhandler.cc b/pdns/dynhandler.cc index 7f4449cefd..bef847764b 100644 --- a/pdns/dynhandler.cc +++ b/pdns/dynhandler.cc @@ -84,14 +84,12 @@ string DLPingHandler(const vector&parts, Utility::pid_t ppid) } string DLShowHandler(const vector&parts, Utility::pid_t ppid) { - std::set blacklist; - blacklist.insert("special-memory-usage"); try { extern StatBag S; string ret("Wrong number of parameters"); if (parts.size() == 2) { if (parts[1] == "*") - ret = S.directory(blacklist); + ret = S.directory(); else ret = S.getValueStr(parts[1]); } diff --git a/pdns/receiver.cc b/pdns/receiver.cc index bd0f7cf9b1..e6686787b3 100644 --- a/pdns/receiver.cc +++ b/pdns/receiver.cc @@ -606,6 +606,8 @@ int main(int argc, char **argv) } declareStats(); + S.blacklist("special-memory-usage"); + DLOG(g_log<& skip) +string StatBag::directory() { string dir; ostringstream o; for(const auto& i: d_stats) { - if (skip.find(i.first) != skip.end()) + if (d_blacklist.find(i.first) != d_blacklist.end()) continue; o<StatBag::getEntries() vector ret; for(const auto& i: d_stats) { - ret.push_back(i.first); + if (d_blacklist.find(i.first) != d_blacklist.end()) + continue; + ret.push_back(i.first); } for(const funcstats_t::value_type& val : d_funcstats) { + if (d_blacklist.find(val.first) != d_blacklist.end()) + continue; ret.push_back(val.first); } @@ -329,6 +333,10 @@ bool StatBag::ringExists(const string &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; template class StatRing; template class StatRing >; diff --git a/pdns/statbag.hh b/pdns/statbag.hh index e1a3998649..f36c211f63 100644 --- a/pdns/statbag.hh +++ b/pdns/statbag.hh @@ -71,6 +71,7 @@ class StatBag typedef map funcstats_t; funcstats_t d_funcstats; bool d_doRings; + std::set d_blacklist; public: StatBag(); //!< Naked constructor. You need to declare keys before this class becomes useful @@ -120,7 +121,7 @@ public: void resizeRing(const string &name, unsigned int newsize); unsigned int getRingSize(const string &name); - string directory(const std::set& skip); //!< Returns a list of all data stored + string directory(); //!< Returns a list of all data stored vector getEntries(); //!< returns a vector with datums (items) string getDescrip(const string &item); //!< Returns the description of this datum/item void exists(const string &key); //!< call this function to throw an exception in case a key does not exist @@ -132,6 +133,7 @@ public: AtomicCounter *getPointer(const string &key); //!< get a direct pointer to the value behind a key. Use this for high performance increments string getValueStr(const string &key); //!< read a value behind a key, and return it as a string string getValueStrZero(const string &key); //!< read a value behind a key, and return it as a string, and zero afterwards + void blacklist(const string &str); }; inline void StatBag::deposit(const string &key, int value)