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));
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>
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)
{
s_lm = lm;
}
- static void doEDNSDumpAndClose(int fd);
+ static uint64_t doEDNSDump(int fd);
static uint64_t doDumpNSSpeeds(int fd);
static uint64_t doDumpThrottleMap(int fd);
static int getRootNS(struct timeval now, asyncresolve_t asyncCallback);