#include "recpacketcache.hh"
#include "cachecleaner.hh"
#include "dns.hh"
+#include "dnsparser.hh"
#include "namespaces.hh"
#include "lock.hh"
#include "dnswriter.hh"
pruneCollection(d_packetCache, maxCached);
}
+uint64_t RecursorPacketCache::doDump(int fd)
+{
+ FILE* fp=fdopen(dup(fd), "w");
+ if(!fp) { // dup probably failed
+ return 0;
+ }
+ fprintf(fp, "; main packet cache dump from thread follows\n;\n");
+ const auto& sidx=d_packetCache.get<1>();
+
+ uint64_t count=0;
+ time_t now=time(0);
+ for(auto i=sidx.cbegin(); i != sidx.cend(); ++i) {
+ count++;
+ try {
+ fprintf(fp, "%s %d %s ; tag %d\n", i->d_name.toString().c_str(), (int32_t)(i->d_ttd - now), DNSRecordContent::NumberToType(i->d_type).c_str(), i->d_tag);
+ }
+ catch(...) {
+ fprintf(fp, "; error printing '%s'\n", i->d_name.empty() ? "EMPTY" : i->d_name.toString().c_str());
+ }
+ }
+ fclose(fp);
+ return count;
+
+}
bool getResponsePacket(unsigned int tag, const std::string& queryPacket, time_t now, std::string* responsePacket, uint32_t* age);
void insertResponsePacket(unsigned int tag, const DNSName& qname, uint16_t qtype, const std::string& queryPacket, const std::string& responsePacket, time_t now, uint32_t ttd);
void doPruneTo(unsigned int maxSize=250000);
+ uint64_t doDump(int fd);
int doWipePacketCache(const DNSName& name, uint16_t qtype=0xffff, bool subtree=false);
void prune();