]> granicus.if.org Git - pdns/commitdiff
slight speedup by testing the TCP sessions for timeouts less often, add 'current...
authorBert Hubert <bert.hubert@netherlabs.nl>
Sat, 17 Jun 2006 14:03:27 +0000 (14:03 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sat, 17 Jun 2006 14:03:27 +0000 (14:03 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@855 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/pdns_recursor.cc
pdns/rec_channel_rec.cc
pdns/syncres.hh

index 5840d5b8f6ea2b1628ea557745da03a43b3f1600..692f4372dc4adf659c9b9ec62c14a3be2335d2ea 100644 (file)
@@ -133,9 +133,7 @@ ArgvMap &arg()
 struct timeval g_now;
 typedef vector<int> tcpserversocks_t;
 
-typedef MTasker<PacketID,string> MT_t;
-MT_t* MT;
-
+MT_t* MT; // the big MTasker
 
 void handleTCPClientWritable(int fd, boost::any& var);
 
@@ -760,7 +758,6 @@ void handleNewUDPQuestion(int fd, boost::any& var)
     }
     try {
       DNSComboWriter* dc = new DNSComboWriter(data, len, g_now);
-      
       dc->setRemote(&fromaddr);
       
       if(dc->d_mdp.d_header.qr) {
@@ -1554,7 +1551,7 @@ int serviceMain(int argc, char*argv[])
       MT->makeThread(houseKeeping,0);
     }
 
-    if(!(counter%11)) {
+    if(!(counter%55)) {
       typedef vector<pair<int, boost::any> > expired_t;
       expired_t expired=g_fdm->getTimeouts(g_now);
        
index ff98f30ef22b51dace9db5ed454320f4308cc965..084209a6a45292ccbf1e4c227e0b54ca7e9988b0 100644 (file)
@@ -1,4 +1,3 @@
-
 #include "utility.hh"
 #include "rec_channel.hh"
 #include <boost/lexical_cast.hpp>
@@ -15,6 +14,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include "logger.hh"
+#include "dnsparser.hh"
 #ifndef WIN32
 #include <sys/resource.h>
 #include <sys/time.h>
@@ -134,6 +134,28 @@ static uint64_t getUserTimeMsec()
 }
 #endif
 
+static string doCurrentQueries()
+{
+  ostringstream ostr;
+
+  ostr << MT->d_waiters.size() <<" currently outstanding questions\n";
+
+  boost::format fmt("%1% %|40t|%2% %|47t|%3% %|63t|%4% %|68t|%5%\n");
+
+  ostr << (fmt % "qname" % "qtype" % "remote" % "tcp" % "chained");
+  int n=0;
+  for(MT_t::waiters_t::iterator mthread=MT->d_waiters.begin(); mthread!=MT->d_waiters.end() && n < 100; ++mthread, ++n) {
+    const PacketID& pident = mthread->key;
+    ostr << (fmt 
+            % pident.domain % DNSRecordContent::NumberToType(pident.type) 
+            % pident.remote.toString() % (pident.sock ? 'Y' : 'n')
+            % (pident.fd == -1 ? 'Y' : 'n')
+            );
+  }
+  ostr <<" - done\n";
+  return ostr.str();
+}
+
 RecursorControlParser::RecursorControlParser()
 {
   addGetStat("questions", &g_stats.qcounter);
@@ -254,6 +276,9 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP
   if(cmd=="top-remotes")
     return doTopRemotes();
 
+  if(cmd=="current-queries")
+    return doCurrentQueries();
+  
   if(cmd=="ping")
     return "pong\n";
 
index bdda17738692565bf7d9c814f4f9e57c0852b6dd..3c7d79a53b2ab2126250900ae7a7b9471e77e8d7 100644 (file)
@@ -453,7 +453,8 @@ struct PacketIDBirthdayCompare: public binary_function<PacketID, PacketID, bool>
   }
 };
 extern MemRecursorCache RC;
-extern MTasker<PacketID,string>* MT;
+typedef MTasker<PacketID,string> MT_t;
+extern MT_t* MT;
 
 struct RecursorStats
 {