]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
make qsize-q more robust
authorbert hubert <bert.hubert@netherlabs.nl>
Thu, 11 Dec 2014 08:41:58 +0000 (09:41 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Thu, 11 Dec 2014 08:41:58 +0000 (09:41 +0100)
pdns/common_startup.cc

index 86bba3fbbc3755da3eef2e4cbe6b5e7f70f45dd9..3e81ba46c5f7e553076948bcab48fb9c8344b131 100644 (file)
@@ -187,6 +187,7 @@ static uint64_t getSysUserTimeMsec(const std::string& str)
 }
 
 static uint64_t getQCount(const std::string& str)
+try
 {
   int totcount=0;
   BOOST_FOREACH(DNSDistributor* d, g_distributors) {
@@ -196,6 +197,16 @@ static uint64_t getQCount(const std::string& str)
   }
   return totcount;
 }
+catch(std::exception& e)
+{
+  L<<Logger::Error<<"Had error retrieving queue sizes: "<<e.what()<<endl;
+  return 0;
+}
+catch(PDNSException& e)
+{
+  L<<Logger::Error<<"Had error retrieving queue sizes: "<<e.reason<<endl;
+  return 0;
+}
 
 static uint64_t getLatency(const std::string& str) 
 {
@@ -283,7 +294,8 @@ void *qthread(void *number)
 {
   DNSPacket *P;
   DNSDistributor *distributor = DNSDistributor::Create(::arg().asNum("distributor-threads", 1)); // the big dispatcher!
-  g_distributors.push_back(distributor);
+  int num = (int)(unsigned long)number;
+  g_distributors[num] = distributor;
   DNSPacket question;
   DNSPacket cached;
 
@@ -458,6 +470,7 @@ void mainthread()
 
   //  fork(); (this worked :-))
   unsigned int max_rthreads= ::arg().asNum("receiver-threads", 1);
+  g_distributors.resize(max_rthreads);
   for(unsigned int n=0; n < max_rthreads; ++n)
     pthread_create(&qtid,0,qthread, reinterpret_cast<void *>(n)); // receives packets