From 1ac4e536a314defe97479db8c9c28202861eb84f Mon Sep 17 00:00:00 2001 From: Bert Hubert Date: Tue, 4 Apr 2006 12:15:20 +0000 Subject: [PATCH] Oops.. Fix bug where records we transmit transparently were not cached properly, leading to new out-queries for each question. Fixed by moving away from crappy string based keys in temporary cache. remove check for --do-ipv6-additional-processing for each packet git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@653 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- pdns/qtype.hh | 6 ++++++ pdns/syncres.cc | 31 +++++++++++++------------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/pdns/qtype.hh b/pdns/qtype.hh index bcf539cf1..3696f48b8 100644 --- a/pdns/qtype.hh +++ b/pdns/qtype.hh @@ -59,6 +59,12 @@ public: code=rhs.code; return *this; } + + bool operator<(const QType& rhs) const + { + return code < rhs.code; + } + bool operator==(const QType &) const; //!< equality operator const string getName() const; //!< Get a string representation of this type diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 1d582e4b1..006180e11 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -471,7 +471,9 @@ int SyncRes::doResolveAt(set nameservers, string auth, const string &qna LOG< > tcache; + typedef map ,set > tcache_t; + tcache_t tcache; + // reap all answers from this packet that are acceptable for(LWRes::res_t::const_iterator i=result.begin();i!=result.end();++i) { if(i->qtype.getCode() < 1024) { @@ -494,7 +496,7 @@ int SyncRes::doResolveAt(set nameservers, string auth, const string &qna rr.d_place=DNSResourceRecord::ANSWER; rr.ttl+=d_now.tv_sec; // rr.ttl=time(0)+10+10*rr.qtype.getCode(); - tcache[toLower(i->qname)+"|"+i->qtype.getName()].insert(rr); + tcache[make_pair(toLower(i->qname),i->qtype)].insert(rr); } } else @@ -502,18 +504,8 @@ int SyncRes::doResolveAt(set nameservers, string auth, const string &qna } // supplant - for(map >::const_iterator i=tcache.begin();i!=tcache.end();++i) { - vectorparts; - stringtok(parts,i->first,"|"); - QType qt; - if(parts.size()==2) { - qt=parts[1]; - RC.replace(parts[0],qt,i->second); - } - else { - qt=parts[0]; - RC.replace("",qt,i->second); - } + for(tcache_t::const_iterator i=tcache.begin();i!=tcache.end();++i) { + RC.replace(i->first.first,i->first.second,i->second); } set nsset; LOG<& ret) LOG< addit; - bool doIPv6AP=::arg().mustDo("aaaa-additional-processing"); + static optional l_doIPv6AP; + if(!l_doIPv6AP) + l_doIPv6AP=::arg().mustDo("aaaa-additional-processing"); + for(vector::const_iterator k=ret.begin();k!=ret.end();++k) if((k->d_place==DNSResourceRecord::ANSWER && k->qtype==QType(QType::MX)) || ((k->d_place==DNSResourceRecord::AUTHORITY || k->d_place==DNSResourceRecord::ANSWER) && k->qtype==QType(QType::NS))) { @@ -631,18 +626,18 @@ void SyncRes::addCruft(const string &qname, vector& ret) string::size_type pos=k->content.find_first_not_of(" \t0123456789"); // chop off the priority if(pos!=string::npos) { doResolve(toLowerCanonic(k->content.substr(pos)), QType(QType::A),addit,1,beenthere); - if(doIPv6AP) + if(*l_doIPv6AP) doResolve(toLowerCanonic(k->content.substr(pos)), QType(QType::AAAA),addit,1,beenthere); } else { doResolve(toLowerCanonic(k->content), QType(QType::A),addit,1,beenthere); - if(doIPv6AP) + if(*l_doIPv6AP) doResolve(toLowerCanonic(k->content.substr(pos)), QType(QType::AAAA),addit,1,beenthere); } } else { doResolve(k->content,QType(QType::A),addit,1,beenthere); - if(doIPv6AP) + if(*l_doIPv6AP) doResolve(k->content,QType(QType::AAAA),addit,1,beenthere); } } -- 2.49.0