]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
implement purging whole lists of domains or suffixes instead of 1 at a time
authorBert Hubert <bert.hubert@netherlabs.nl>
Mon, 23 Jun 2008 06:04:18 +0000 (06:04 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Mon, 23 Jun 2008 06:04:18 +0000 (06:04 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1221 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/communicator.cc
pdns/dynhandler.cc
pdns/packetcache.cc
pdns/packetcache.hh

index 912535abfa65f509b05f08066baadc17d4946a7a..d536fe9ffc4032c093b00a2063f200f719965116 100644 (file)
@@ -221,7 +221,9 @@ void CommunicatorClass::masterUpdateCheck(PacketHandler *P)
   
   for(vector<DomainInfo>::const_iterator i=cmdomains.begin();i!=cmdomains.end();++i) {
     extern PacketCache PC;
-    PC.purge(i->zone); // fixes cvstrac ticket #30
+    vector<string> topurge;
+    topurge.push_back(i->zone);
+    PC.purge(topurge); // fixes cvstrac ticket #30
     queueNotifyDomain(i->zone,P->getBackend());
     i->backend->setNotified(i->id,i->serial); 
   }
index 05eb3dad9faf72448614a26b8f37a011fd7354a5..580c1e1803cc3585460358cde855a5e4460ed3f9 100644 (file)
@@ -116,7 +116,7 @@ string DLPurgeHandler(const vector<string>&parts, Utility::pid_t ppid)
   int ret;
 
   if(parts.size()>1)
-    ret=PC.purge(parts[1]);
+    ret=PC.purge(parts);
   else
     ret=PC.purge();
   os<<ret;
index 337109fc3ec3ec6fc6dda0bde04036a1dc128a29..c18dea293114c41506521caef6723e607f083ee8 100644 (file)
@@ -155,12 +155,12 @@ void PacketCache::insert(const string &qname, const QType& qtype, CacheEntryType
 }
 
 /** purges entries from the packetcache. If match ends on a $, it is treated as a suffix */
-int PacketCache::purge(const string &match)
+int PacketCache::purge(const vector<string> &matches)
 {
   WriteLock l(&d_mut);
   int delcount=0;
-
-  if(match.empty()) {
+  
+  if(matches.empty()) {
     delcount = d_map.size();
     d_map.clear();
     *statnumentries=0;
@@ -210,31 +210,33 @@ int PacketCache::purge(const string &match)
      'www.userpowerdns.com'
 
   */
-  if(ends_with(match, "$")) {
-    string suffix(match);
-    suffix.resize(suffix.size()-1);
-
-    //    cerr<<"Begin dump!"<<endl;
-    cmap_t::const_iterator iter = d_map.lower_bound(tie(suffix));
-    cmap_t::const_iterator start=iter;
-    string dotsuffix = "."+suffix;
-
-    for(; iter != d_map.end(); ++iter) {
-      if(!iequals(iter->qname, suffix) && !iends_with(iter->qname, dotsuffix)) {
-       //      cerr<<"Stopping!"<<endl;
-       break;
+  for(vector<string>::const_iterator match = ++matches.begin(); match != matches.end() ; ++match) {
+    if(ends_with(*match, "$")) {
+      string suffix(*match);
+      suffix.resize(suffix.size()-1);
+
+      //    cerr<<"Begin dump!"<<endl;
+      cmap_t::const_iterator iter = d_map.lower_bound(tie(suffix));
+      cmap_t::const_iterator start=iter;
+      string dotsuffix = "."+suffix;
+
+      for(; iter != d_map.end(); ++iter) {
+       if(!iequals(iter->qname, suffix) && !iends_with(iter->qname, dotsuffix)) {
+         //    cerr<<"Stopping!"<<endl;
+         break;
+       }
+       //      cerr<<"Will erase '"<<iter->qname<<"'\n";
+
+       delcount++;
       }
-      //      cerr<<"Will erase '"<<iter->qname<<"'\n";
-
-      delcount++;
+      //    cerr<<"End dump!"<<endl;
+      d_map.erase(start, iter);
+    }
+    else {
+      delcount=d_map.count(tie(*match));
+      pair<cmap_t::iterator, cmap_t::iterator> range = d_map.equal_range(tie(*match));
+      d_map.erase(range.first, range.second);
     }
-    //    cerr<<"End dump!"<<endl;
-    d_map.erase(start, iter);
-  }
-  else {
-    delcount=d_map.count(tie(match));
-    pair<cmap_t::iterator, cmap_t::iterator> range = d_map.equal_range(tie(match));
-    d_map.erase(range.first, range.second);
   }
   *statnumentries=d_map.size();
   return delcount;
index 2a1412cbaed32622f5ca3e7e6eda713ac37e91de..7ba0b20e3c0e77ac26daaa5148276bd70e0fdf51 100644 (file)
@@ -90,7 +90,7 @@ public:
 
   int size(); //!< number of entries in the cache
   void cleanup(); //!< force the cache to preen itself from expired packets
-  int purge(const string &prefix="");
+  int purge(const vector<string>&matches= vector<string>());
 
   map<char,int> getCounts();
 private: