]> granicus.if.org Git - pdns/commitdiff
fix issue where we would submit nameserver performance stats for an empty DNSName...
authorbert hubert <bert.hubert@powerdns.com>
Wed, 1 Nov 2017 17:40:01 +0000 (18:40 +0100)
committerbert hubert <bert.hubert@powerdns.com>
Wed, 1 Nov 2017 17:40:01 +0000 (18:40 +0100)
Also added some error messages in case dump-nsspeeds ever throws an exception again.

pdns/rec_channel_rec.cc
pdns/syncres.cc

index 2f47b60bec53f39557fad3bb5221bba1bb3f54ee..7daaa998a0e03051e171b70b27e0fe5b4602a863 100644 (file)
@@ -215,7 +215,16 @@ string doDumpNSSpeeds(T begin, T end)
   try {
     total = broadcastAccFunction<uint64_t>(boost::bind(pleaseDumpNSSpeeds, fd));
   }
-  catch(...){}
+  catch(std::exception& e)
+  {
+    close(fd);
+    return "error dumping NS speeds: "+string(e.what())+"\n";
+  }
+  catch(PDNSException& e)
+  {
+    close(fd);
+    return "error dumping NS speeds: "+e.reason+"\n";
+  }
 
   close(fd);
   return "dumped "+std::to_string(total)+" records\n";
index 40e273b6dbf61fcf99d66769365aca46d4ab0f71..504aa61cee718b2efec7803a1dafd7606315a323 100644 (file)
@@ -368,7 +368,9 @@ uint64_t SyncRes::doDumpNSSpeeds(int fd)
   for(const auto& i : t_sstorage.nsSpeeds)
   {
     count++;
-    fprintf(fp, "%s -> ", i.first.toString().c_str());
+
+    // an <empty> can appear hear in case of authoritative (hosted) zones
+    fprintf(fp, "%s -> ", i.first.toLogString().c_str());
     for(const auto& j : i.second.d_collection)
     {
       // typedef vector<pair<ComboAddress, DecayingEwma> > collection_t;
@@ -685,7 +687,6 @@ vector<ComboAddress> SyncRes::getAddrs(const DNSName &qname, unsigned int depth,
 
   if(ret.size() > 1) {
     map<ComboAddress, double> speeds;
-
     auto& collection = t_sstorage.nsSpeeds[qname].d_collection;
     for(const auto& val: ret) {
       double speed;
@@ -1202,8 +1203,10 @@ inline vector<DNSName> SyncRes::shuffleInSpeedOrder(NsSet &tnameservers, const s
 {
   vector<DNSName> rnameservers;
   rnameservers.reserve(tnameservers.size());
-  for(const auto& tns:tnameservers) {
+  for(const auto& tns: tnameservers) {
     rnameservers.push_back(tns.first);
+    if(tns.first.empty()) // this was an authoritative OOB zone, don't pollute the nsSpeeds with that
+      return rnameservers;
   }
   map<DNSName, double> speeds;