]> granicus.if.org Git - pdns/commitdiff
Fixed Habbie's suggestions (https://github.com/PowerDNS/pdns/pull/1220#issuecomment...
authorFusl <root@hallowe.lt>
Tue, 21 Jan 2014 14:57:42 +0000 (15:57 +0100)
committerFusl <root@hallowe.lt>
Tue, 21 Jan 2014 14:57:42 +0000 (15:57 +0100)
pdns/Makefile-recursor
pdns/dist-recursor
pdns/dynhandler.cc
pdns/pdns_recursor.cc
pdns/rec_channel_rec.cc
pdns/receiver.cc
pdns/responsestats.cc
pdns/responsestats.hh

index ba5c2acd99d575c439f328e6b7f30675c738e009..d6cc1d9749a48bc09738493cfed1aaa29b08fd44 100644 (file)
@@ -21,7 +21,7 @@ dnswriter.o dnsrecords.o rcpgenerator.o base64.o zoneparser-tng.o \
 rec_channel.o rec_channel_rec.o selectmplexer.o sillyrecords.o \
 dns_random.o ext/polarssl-1.3.2/library/aes.o ext/polarssl-1.3.2/library/padlock.o dnslabeltext.o \
 lua-pdns.o lua-recursor.o randomhelper.o recpacketcache.o dns.o \
-reczones.o base32.o nsecrecords.o json.o json_ws.o version.o
+reczones.o base32.o nsecrecords.o json.o json_ws.o version.o responsestats.o
 
 REC_CONTROL_OBJECTS=rec_channel.o rec_control.o arguments.o misc.o \
        unix_utility.o logger.o qtype.o
index 2ecee16b7dd1b3aa6e5ba5d7ce3b9f0f7a20cb7f..c0e4c973c5f17164ee47ce589c15f0eb5acf99f4 100755 (executable)
@@ -25,7 +25,8 @@ recursor_cache.hh rec_channel.hh qtype.hh misc.hh dns.hh syncres.hh \
 sstuff.hh mtasker.hh mtasker.cc lwres.hh logger.hh pdnsexception.hh \
 mplexer.hh \
 dns_random.hh lua-pdns.hh lua-recursor.hh namespaces.hh \
-recpacketcache.hh base32.hh cachecleaner.hh json.hh version.hh"
+recpacketcache.hh base32.hh cachecleaner.hh json.hh version.hh \
+responsestats.hh"
 
 CFILES="syncres.cc  misc.cc unix_utility.cc qtype.cc \
 logger.cc arguments.cc  lwres.cc pdns_recursor.cc  \
@@ -34,7 +35,8 @@ base64.cc  zoneparser-tng.cc  rec_channel.cc rec_channel_rec.cc rec_control.cc \
 selectmplexer.cc epollmplexer.cc kqueuemplexer.cc portsmplexer.cc pdns_hw.cc \
 sillyrecords.cc lua-pdns.cc lua-recursor.cc randomhelper.cc \
 devpollmplexer.cc recpacketcache.cc dns.cc reczones.cc base32.cc nsecrecords.cc \
-dnslabeltext.cc json.cc json_ws.cc json_ws.hh version.cc dns_random.cc"
+dnslabeltext.cc json.cc json_ws.cc json_ws.hh version.cc dns_random.cc \
+responsestats.cc"
 
 cd docs
 make pdns_recursor.1 rec_control.1
index 663a47f8fc35b833a88d570bf41eb742f9037ec0..308b87aae25725b0cf874f7018d96f324863dd56 100644 (file)
@@ -31,6 +31,9 @@
 #include "communicator.hh"
 #include "dnsseckeeper.hh"
 #include "nameserver.hh"
+#include "responsestats.hh"
+
+extern ResponseStats g_rs;
 
 static bool s_pleasequit;
 static string d_status;
@@ -160,14 +163,7 @@ string DLCCHandler(const vector<string>&parts, Utility::pid_t ppid)
 
 string DLQTypesHandler(const vector<string>&parts, Utility::pid_t ppid)
 {
-  typedef map<uint16_t, uint64_t> qtypenums_t;
-  qtypenums_t qtypenums = g_rs.getQTypeResponseCounts();
-  ostringstream os;
-  boost::format fmt("%s\t%d\n");
-  BOOST_FOREACH(const qtypenums_t::value_type& val, qtypenums) {
-    os << (fmt %DNSRecordContent::NumberToType( val.first) % val.second).str();
-  }
-  return os.str();
+  return g_rs.getQTypeReport();
 }
 
 string DLRSizesHandler(const vector<string>&parts, Utility::pid_t ppid)
index 45df2f61651a1ade67013549977d15ef0172feb1..373632fcc72d0c380c779758f3728bd442c398e8 100644 (file)
@@ -567,7 +567,6 @@ void startDoResolve(void *p)
     }
     
     if(res == RecursorBehaviour::DROP) {
-      g_rs.submitResponse(dc->d_mdp.d_qtype, 0, !dc->d_tcp);
       delete dc;
       dc=0;
       return;
index db079be076c96683ede2dcac3e022bf3d66c7acb..d31bde3cb2b293499a740c1aa526198d1eabadd9 100644 (file)
@@ -425,18 +425,6 @@ uint64_t doGetMallocated()
 
 extern ResponseStats g_rs;
 
-string qtypeList()
-{
-  typedef map<uint16_t, uint64_t> qtypenums_t;
-  qtypenums_t qtypenums = g_rs.getQTypeResponseCounts();
-  ostringstream os;
-  boost::format fmt("%s\t%d\n");
-  BOOST_FOREACH(const qtypenums_t::value_type& val, qtypenums) {
-    os << (fmt %DNSRecordContent::NumberToType( val.first) % val.second).str();
-  }
-  return os.str();
-}
-
 RecursorControlParser::RecursorControlParser()
 {
   addGetStat("questions", &g_stats.qcounter);
@@ -605,6 +593,8 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP
 "get [key1] [key2] ..             get specific statistics\n"
 "get-all                          get all statistics\n"
 "get-parameter [key1] [key2] ..   get configuration parameters\n"
+"get-qtypelist                    get QType statistics\n"
+"                                 notice: queries from cache aren't being counted yet\n"
 "help                             get this list\n"
 "ping                             check that all threads are alive\n"
 "quit                             stop the recursor daemon\n"
@@ -693,7 +683,7 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP
   }
   
   if(cmd=="get-qtypelist") {
-    return qtypeList();
+    return g_rs.getQTypeReport();
   }
   
   return "Unknown command '"+cmd+"', try 'help'\n";
index ef8739a4eb8fdcfbeef64583391f7c203f5e2932..421c1127a08fbea3a3c0508c00cc5cc3cef394fd 100644 (file)
@@ -67,7 +67,6 @@
 #include "dnsrecords.hh"
 #include "version.hh"
 
-
 time_t s_starttime;
 
 string s_programname="pdns"; // used in packethandler.cc
index 6e018d0227a4f089b6a8abe6e997a29812e4d791..ce45f6546288b9211308d1f55f5d06279eccab1b 100644 (file)
@@ -2,6 +2,8 @@
 #include <limits>
 #include "namespaces.hh"
 #include "logger.hh"
+#include "boost/foreach.hpp"
+#include "dnsparser.hh"
 
 ResponseStats::ResponseStats()
 {
@@ -54,3 +56,15 @@ map<uint16_t, uint64_t> ResponseStats::getSizeResponseCounts()
   }
   return ret;
 }
+
+string ResponseStats::getQTypeReport()
+{
+  typedef map<uint16_t, uint64_t> qtypenums_t;
+  qtypenums_t qtypenums = getQTypeResponseCounts();
+  ostringstream os;
+  boost::format fmt("%s\t%d\n");
+  BOOST_FOREACH(const qtypenums_t::value_type& val, qtypenums) {
+    os << (fmt %DNSRecordContent::NumberToType( val.first) % val.second).str();
+  }
+  return os.str();
+}
\ No newline at end of file
index e2d768a32cebe8170d0ce616e319bd9bc431c530..45fe23225aa012c0d14702f1036641a68923c242 100644 (file)
@@ -10,6 +10,7 @@ public:
   void submitResponse(uint16_t qtype, uint16_t respsize, bool udpOrTCP);
   map<uint16_t, uint64_t> getQTypeResponseCounts();
   map<uint16_t, uint64_t> getSizeResponseCounts();
+  string getQTypeReport();
 
 private:
   vector<AtomicCounter> d_qtypecounters;