Changeset 1265

Show
Ignore:
Timestamp:
10/05/08 11:49:53 (2 years ago)
Author:
ahu
Message:

reported by Andreas Jakum & investigated by Stefan Schmidt - make sure we don't hammer parent zones in case of failed delegations to servers that don't exist at all. Only invalidate once every 10 seconds

Location:
trunk/pdns/pdns
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/recursor_cache.cc

    r1262 r1265  
    234234 
    235235    //    cerr<<"time left : "<<ttd - now<<", "<< (res ? res->size() : 0) <<"\n"; 
    236     return (unsigned int)ttd-now; 
     236    return (int)ttd-now; 
    237237  } 
    238238  return -1; 
     
    363363} 
    364364 
     365bool MemRecursorCache::doAgeCache(time_t now, const string& name, uint16_t qtype, int32_t newTTL) 
     366{ 
     367  cache_t::iterator iter = d_cache.find(tie(name, qtype)); 
     368  if(iter == d_cache.end())  
     369    return false; 
     370 
     371  int32_t ttl = iter->getTTD() - now; 
     372  if(ttl < 0)  
     373    return false;  // would be dead anyhow 
     374 
     375  if(ttl > newTTL) { 
     376    d_cachecachevalid=false; 
     377 
     378    ttl = newTTL; 
     379    uint32_t newTTD = now + ttl; 
     380     
     381    CacheEntry ce = *iter; 
     382    for(vector<StoredRecord>::iterator j = ce.d_records.begin() ; j != ce.d_records.end(); ++j)  { 
     383      j->d_ttd = newTTD; 
     384    } 
     385     
     386    d_cache.replace(iter, ce); 
     387    return true; 
     388  } 
     389  return false; 
     390} 
     391 
     392 
    365393void MemRecursorCache::doDumpAndClose(int fd) 
    366394{ 
  • trunk/pdns/pdns/recursor_cache.hh

    r1183 r1265  
    4040  void doDumpAndClose(int fd); 
    4141  int doWipeCache(const string& name, uint16_t qtype=0xffff); 
     42  bool doAgeCache(time_t now, const string& name, uint16_t qtype, int32_t newTTL); 
    4243  uint64_t cacheHits, cacheMisses; 
    4344  bool d_followRFC2181; 
  • trunk/pdns/pdns/syncres.cc

    r1230 r1265  
    608608        LOG<<prefix<<qname<<": Failed to resolve via any of the "<<(unsigned int)rnameservers.size()<<" offered NS at level '"<<auth<<"'"<<endl; 
    609609        if(auth!="." && flawedNSSet) { 
    610           g_stats.nsSetInvalidations++; 
    611           LOG<<prefix<<qname<<": Invalidating nameservers for level '"<<auth<<"', next query might succeed"<<endl; 
    612           RC.doWipeCache(auth, QType::NS); 
     610          LOG<<prefix<<qname<<": Ageing nameservers for level '"<<auth<<"', next query might succeed"<<endl; 
     611          if(RC.doAgeCache(d_now.tv_sec, auth, QType::NS, 10)) 
     612            g_stats.nsSetInvalidations++; 
    613613        } 
    614614        return -1;