]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Do the edns dumping harder. 8542/head
authorphonedph1 <phoned@gmail.com>
Tue, 16 Oct 2018 02:07:50 +0000 (02:07 +0000)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 18 Nov 2019 11:21:36 +0000 (11:21 +0000)
(cherry picked from commit addde5c1785f040f803bc5154433b0574a197216)

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

index feb58074f569286e7b77c5969e31fb581aa2d4da..1acbac06ab03cfbdacbc94d331d2fe18f606736a 100644 (file)
@@ -189,6 +189,11 @@ static uint64_t* pleaseDump(int fd)
   return new uint64_t(t_RC->doDump(fd) + dumpNegCache(SyncRes::t_sstorage.negcache, fd) + t_packetCache->doDump(fd));
 }
 
+static uint64_t* pleaseDumpEDNSMap(int fd)
+{
+  return new uint64_t(SyncRes::doEDNSDump(fd));
+}
+
 static uint64_t* pleaseDumpNSSpeeds(int fd)
 {
   return new uint64_t(SyncRes::doDumpNSSpeeds(fd));
@@ -259,10 +264,14 @@ string doDumpEDNSStatus(T begin, T end)
   int fd=open(fname.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0660);
   if(fd < 0) 
     return "Error opening dump file for writing: "+string(strerror(errno))+"\n";
+  uint64_t total = 0;
+  try {
+    total = broadcastAccFunction<uint64_t>(boost::bind(pleaseDumpEDNSMap, fd));
+  }
+  catch(...){}
 
-  SyncRes::doEDNSDumpAndClose(fd);
-
-  return "done\n";
+  close(fd);
+  return "dumped "+std::to_string(total)+" records\n";
 }
 
 template<typename T>
index 1d4d6395d807f16d291baad32df09856bb999469..392f63546cc461b7faa955b3c0b6b959a49c176c 100644 (file)
@@ -355,18 +355,21 @@ bool SyncRes::doOOBResolve(const DNSName &qname, const QType &qtype, vector<DNSR
   return doOOBResolve(iter->second, qname, qtype, ret, res);
 }
 
-void SyncRes::doEDNSDumpAndClose(int fd)
+uint64_t SyncRes::doEDNSDump(int fd)
 {
-  FILE* fp=fdopen(fd, "w");
+  FILE* fp=fdopen(dup(fd), "w");
   if (!fp) {
-    return;
+    return 0;
   }
-  fprintf(fp,"IP Address\tMode\tMode last updated at\n");
+  uint64_t count = 0;
+
+  fprintf(fp,"; edns from thread follows\n;\n");
   for(const auto& eds : t_sstorage.ednsstatus) {
+    count++;
     fprintf(fp, "%s\t%d\t%s", eds.first.toString().c_str(), (int)eds.second.mode, ctime(&eds.second.modeSetAt));
   }
-
   fclose(fp);
+  return count;
 }
 
 uint64_t SyncRes::doDumpNSSpeeds(int fd)
index 72852cdfc56e23c38359064681c008ddae5ae635..d4146449c55cc8d539d653c80f41f66ee1da8ff7 100644 (file)
@@ -392,7 +392,7 @@ public:
   {
     s_lm = lm;
   }
-  static void doEDNSDumpAndClose(int fd);
+  static uint64_t doEDNSDump(int fd);
   static uint64_t doDumpNSSpeeds(int fd);
   static int getRootNS(struct timeval now, asyncresolve_t asyncCallback);
   static void clearDelegationOnly()