]> granicus.if.org Git - pdns/commitdiff
Solve ticket 281, where we cache nxdomains longer than configured because of the...
authorBert Hubert <bert.hubert@netherlabs.nl>
Fri, 6 Aug 2010 20:10:04 +0000 (20:10 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Fri, 6 Aug 2010 20:10:04 +0000 (20:10 +0000)
Also solved anomaly where SOA was initially the original length, and would decrease to the limited ttl on the second query

git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1679 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/syncres.cc

index 71878efe5675540ca338186b3d183478f999ab54..f1a66712599d07ed3738fb81f55657bbaca67710 100644 (file)
@@ -1005,16 +1005,19 @@ int SyncRes::doResolveAt(set<string, CIStringCompare> nameservers, string auth,
       bool done=false, realreferral=false, negindic=false;
       string newauth, soaname, newtarget;
 
-      for(LWResult::res_t::const_iterator i=lwr.d_result.begin();i!=lwr.d_result.end();++i) {
+      for(LWResult::res_t::iterator i=lwr.d_result.begin();i!=lwr.d_result.end();++i) {
         if(i->d_place==DNSResourceRecord::AUTHORITY && dottedEndsOn(qname,i->qname) && i->qtype.getCode()==QType::SOA && 
            lwr.d_rcode==RCode::NXDomain) {
           LOG<<prefix<<qname<<": got negative caching indication for RECORD '"<<qname+"'"<<endl;
-          ret.push_back(*i);
+          i->ttl = min(i->ttl, s_maxnegttl);
+         ret.push_back(*i);
 
           NegCacheEntry ne;
 
           ne.d_qname=i->qname;
-          ne.d_ttd=d_now.tv_sec + min(i->ttl, s_maxnegttl); // controversial
+          
+         ne.d_ttd=d_now.tv_sec + i->ttl;
+         
           ne.d_name=qname;
           ne.d_qtype=QType(0); // this encodes 'whole record'
           
@@ -1057,10 +1060,11 @@ int SyncRes::doResolveAt(set<string, CIStringCompare> nameservers, string auth,
             LOG<<prefix<<qname<<": Hang on! Got a redirect to '"<<newtarget<<"' already"<<endl;
           }
           else {
+           i-> ttl = min(s_maxnegttl, i->ttl);
             ret.push_back(*i);
             NegCacheEntry ne;
             ne.d_qname=i->qname;
-            ne.d_ttd=d_now.tv_sec + min(s_maxnegttl, i->ttl);
+            ne.d_ttd=d_now.tv_sec + i->ttl;
             ne.d_name=qname;
             ne.d_qtype=qtype;
             if(qtype.getCode()) {  // prevents us from blacking out a whole domain