}
// cerr<<"time left : "<<ttd - now<<", "<< (res ? res->size() : 0) <<"\n";
- return (unsigned int)ttd-now;
+ return (int)ttd-now;
}
return -1;
}
return count;
}
+bool MemRecursorCache::doAgeCache(time_t now, const string& name, uint16_t qtype, int32_t newTTL)
+{
+ cache_t::iterator iter = d_cache.find(tie(name, qtype));
+ if(iter == d_cache.end())
+ return false;
+
+ int32_t ttl = iter->getTTD() - now;
+ if(ttl < 0)
+ return false; // would be dead anyhow
+
+ if(ttl > newTTL) {
+ d_cachecachevalid=false;
+
+ ttl = newTTL;
+ uint32_t newTTD = now + ttl;
+
+ CacheEntry ce = *iter;
+ for(vector<StoredRecord>::iterator j = ce.d_records.begin() ; j != ce.d_records.end(); ++j) {
+ j->d_ttd = newTTD;
+ }
+
+ d_cache.replace(iter, ce);
+ return true;
+ }
+ return false;
+}
+
+
void MemRecursorCache::doDumpAndClose(int fd)
{
FILE* fp=fdopen(fd, "w");
void doSlash(int perc);
void doDumpAndClose(int fd);
int doWipeCache(const string& name, uint16_t qtype=0xffff);
+ bool doAgeCache(time_t now, const string& name, uint16_t qtype, int32_t newTTL);
uint64_t cacheHits, cacheMisses;
bool d_followRFC2181;
if(tns==rnameservers.end()) {
LOG<<prefix<<qname<<": Failed to resolve via any of the "<<(unsigned int)rnameservers.size()<<" offered NS at level '"<<auth<<"'"<<endl;
if(auth!="." && flawedNSSet) {
- g_stats.nsSetInvalidations++;
- LOG<<prefix<<qname<<": Invalidating nameservers for level '"<<auth<<"', next query might succeed"<<endl;
- RC.doWipeCache(auth, QType::NS);
+ LOG<<prefix<<qname<<": Ageing nameservers for level '"<<auth<<"', next query might succeed"<<endl;
+ if(RC.doAgeCache(d_now.tv_sec, auth, QType::NS, 10))
+ g_stats.nsSetInvalidations++;
}
return -1;
}