From f40c8545d2e672a9a293d37ca08ac4f1946c0389 Mon Sep 17 00:00:00 2001 From: Bert Hubert Date: Fri, 28 Apr 2006 07:14:14 +0000 Subject: [PATCH] fix bug where we temporarily would not be doing negative caching for 5 minutes at a time after 1 hour of blanking out a domain. Apologies to the root-server operators and others. Also, we did not limit the max negative caching time for all cases. git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@783 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- pdns/syncres.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pdns/syncres.cc b/pdns/syncres.cc index d8607df24..93f25d0b6 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -676,7 +676,12 @@ int SyncRes::doResolveAt(set nameservers, string auth, ne.d_ttd=d_now.tv_sec + min(i->ttl, s_maxnegttl); // controversial ne.d_name=qname; ne.d_qtype=QType(0); - s_negcache.insert(ne); + + pair res=s_negcache.insert(ne); + if(!res.second) { + s_negcache.erase(res.first); + s_negcache.insert(ne); + } negindic=true; } else if(i->d_place==DNSResourceRecord::ANSWER && i->qname==qname && i->qtype.getCode()==QType::CNAME && (!(qtype==QType(QType::CNAME)))) { @@ -711,11 +716,16 @@ int SyncRes::doResolveAt(set nameservers, string auth, NegCacheEntry ne; ne.d_qname=i->qname; - ne.d_ttd=d_now.tv_sec + min(3600U,i->ttl); + ne.d_ttd=d_now.tv_sec + min(s_maxnegttl, i->ttl); ne.d_name=qname; ne.d_qtype=qtype; - if(qtype.getCode()) // prevents us from blacking out a whole domain - s_negcache.insert(ne); + if(qtype.getCode()) { // prevents us from blacking out a whole domain + pair res=s_negcache.insert(ne); + if(!res.second) { + s_negcache.erase(res.first); + s_negcache.insert(ne); + } + } negindic=true; } } -- 2.40.0