Changeset 129
- Timestamp:
- 01/13/03 23:36:34 (10 years ago)
- Location:
- trunk/pdns/pdns
- Files:
-
- 2 modified
-
pdns_recursor.cc (modified) (5 diffs)
-
syncres.cc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/pdns_recursor.cc
r128 r129 18 18 */ 19 19 20 21 20 #include <iostream> 22 21 #include <errno.h> … … 101 100 typedef map<string,set<DNSResourceRecord> > cache_t; 102 101 cache_t cache; 102 int cacheHits, cacheMisses; 103 103 int getCache(const string &qname, const QType& qt, set<DNSResourceRecord>* res) 104 104 { … … 107 107 if(res) 108 108 *res=j->second; 109 cacheHits++; 109 110 return (unsigned int)j->second.begin()->ttl-time(0); 110 111 } 112 cacheMisses++; 111 113 return -1; 112 114 } … … 296 298 PacketID pident; 297 299 init(); 300 int counter=0; 298 301 for(;;) { 299 302 while(MT.schedule()); // housekeeping, let threads do their thing … … 361 364 cout<<"new question arrived for '"<<P.qdomain<<"|"<<P.qtype.getName()<<"' from "<<P.getRemote()<<endl; 362 365 MT.makeThread(startDoResolve,(void*)new DNSPacket(P)); 366 if(!((counter++)%100)) { 367 cout<<"stats: "<<counter<<" questions, "<<cache.size()<<" cache entries, "<<(cacheHits*100.0)/(cacheHits+cacheMisses)<<"% cache hits"<<endl; 368 } 363 369 } 364 370 } -
trunk/pdns/pdns/syncres.cc
r128 r129 142 142 template<class MultiPlexor>bool SyncRes<MultiPlexor>::doCNAMECacheCheck(const string &qname, const QType &qtype, vector<DNSResourceRecord>&ret, int depth, int &res) 143 143 { 144 if(depth>10) { 145 cout<<prefix<<qname<<": CNAME loop too deep, depth="<<depth<<endl; 146 res=RCode::ServFail; 147 return true; 148 } 149 144 150 string prefix, tuple=toLower(qname)+"|CNAME"; 145 151 prefix.assign(3*depth, ' '); … … 323 329 324 330 bool done=false, realreferral=false, negindic=false; 325 string newauth, soaname ;331 string newauth, soaname, newtarget; 326 332 327 333 for(LWRes::res_t::const_iterator i=result.begin();i!=result.end();++i) { … … 333 339 } 334 340 else if(i->d_place==DNSResourceRecord::ANSWER && i->qname==qname && i->qtype.getCode()==QType::CNAME && (!(qtype==QType(QType::CNAME)))) { 335 cout<<prefix<<qname<<": got a CNAME referral, starting over with "<<i->content<<endl<<endl;336 341 ret.push_back(*i); 337 set<GetBestNSAnswer>beenthere2; 338 return doResolve(i->content, qtype, ret,0,beenthere2); 342 newtarget=i->content; 339 343 } 340 344 // for ANY answers we *must* have an authoritive answer … … 368 372 return 0; 369 373 } 374 if(!newtarget.empty()) { 375 cout<<prefix<<qname<<": status=got a CNAME referral, starting over with "<<newtarget<<endl<<endl; 376 set<GetBestNSAnswer>beenthere2; 377 return doResolve(newtarget, qtype, ret,0,beenthere2); 378 } 370 379 else if(realreferral) { 371 380 cout<<prefix<<qname<<": status=did not resolve, got "<<nsset.size()<<" NS, looping to them"<<endl;