Skip to content

Instantly share code, notes, and snippets.

@Habbie
Created April 26, 2013 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Habbie/5466696 to your computer and use it in GitHub Desktop.
Save Habbie/5466696 to your computer and use it in GitHub Desktop.
Patch for functionality
--- a/rec_channel_rec.cc 2010-12-30 12:07:59.000000000 +0200
+++ b/rec_channel_rec.cc 2011-01-10 10:42:34.413677661 +0200
@@ -179,7 +179,8 @@
uint64_t* pleaseWipeCache(const std::string& canon)
{
- return new uint64_t(t_RC->doWipeCache(canon));
+ // clear packet cache too
+ return new uint64_t(t_RC->doWipeCache(canon) + t_packetCache->doWipePacketCache(canon));
}
@@ -570,8 +571,7 @@
if(cmd=="dump-ednsstatus" || cmd=="dump-edns")
return doDumpEDNSStatus(begin, end);
-
- if(cmd=="wipe-cache")
+ if(cmd=="wipe-cache" || cmd=="flushname")
return doWipeCache(begin, end);
if(cmd=="reload-lua-script")
--- a/recpacketcache.cc 2010-12-30 12:07:59.000000000 +0200
+++ b/recpacketcache.cc 2011-01-10 12:03:21.663870105 +0200
@@ -12,6 +12,28 @@
d_hits = d_misses = 0;
}
+int RecursorPacketCache::doWipePacketCache(const string& name, uint16_t qtype)
+{
+ int count=0;
+ for(packetCache_t::iterator iter = d_packetCache.begin(); iter != d_packetCache.end();)
+ {
+ const struct dnsheader* packet = reinterpret_cast<const struct dnsheader*>((*iter).d_packet.c_str());
+ if (packet->qdcount>0)
+ {
+ // find out type
+ const struct dnsrecordheader *header = reinterpret_cast<const struct dnsrecordheader*>((*iter).d_packet.c_str()+sizeof(struct dnsheader));
+ uint16_t type = header->d_type;
+ std::string domain=questionExpand((*iter).d_packet.c_str(), (*iter).d_packet.size(), type);
+ if (name == domain)
+ {
+ iter = d_packetCache.erase(iter);
+ count++;
+ } else iter++;
+ }
+ }
+ return count;
+}
+
bool RecursorPacketCache::getResponsePacket(const std::string& queryPacket, time_t now,
std::string* responsePacket, uint32_t* age)
{
--- a/recpacketcache.hh 2010-12-30 12:07:59.000000000 +0200
+++ b/recpacketcache.hh 2011-01-10 10:31:42.733685029 +0200
@@ -22,6 +22,7 @@
bool getResponsePacket(const std::string& queryPacket, time_t now, std::string* responsePacket, uint32_t* age);
void insertResponsePacket(const std::string& responsePacket, time_t now, uint32_t ttd);
void doPruneTo(unsigned int maxSize=250000);
+ int doWipePacketCache(const string& name, uint16_t qtype=0xffff);
void prune();
uint64_t d_hits, d_misses;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment