Changeset 129

Show
Ignore:
Timestamp:
01/13/03 23:36:34 (10 years ago)
Author:
ahu
Message:

more work

Location:
trunk/pdns/pdns
Files:
2 modified

Legend:

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

    r128 r129  
    1818*/ 
    1919  
    20  
    2120#include <iostream> 
    2221#include <errno.h> 
     
    101100typedef map<string,set<DNSResourceRecord> > cache_t; 
    102101cache_t cache; 
     102int cacheHits, cacheMisses; 
    103103int getCache(const string &qname, const QType& qt, set<DNSResourceRecord>* res) 
    104104{ 
     
    107107    if(res) 
    108108      *res=j->second; 
     109    cacheHits++; 
    109110    return (unsigned int)j->second.begin()->ttl-time(0); 
    110111  } 
     112  cacheMisses++; 
    111113  return -1; 
    112114} 
     
    296298    PacketID pident; 
    297299    init();     
     300    int counter=0; 
    298301    for(;;) { 
    299302      while(MT.schedule()); // housekeeping, let threads do their thing 
     
    361364            cout<<"new question arrived for '"<<P.qdomain<<"|"<<P.qtype.getName()<<"' from "<<P.getRemote()<<endl; 
    362365            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            } 
    363369          } 
    364370        } 
  • trunk/pdns/pdns/syncres.cc

    r128 r129  
    142142template<class MultiPlexor>bool SyncRes<MultiPlexor>::doCNAMECacheCheck(const string &qname, const QType &qtype, vector<DNSResourceRecord>&ret, int depth, int &res) 
    143143{ 
     144  if(depth>10) { 
     145    cout<<prefix<<qname<<": CNAME loop too deep, depth="<<depth<<endl; 
     146    res=RCode::ServFail; 
     147    return true; 
     148  } 
     149     
    144150  string prefix, tuple=toLower(qname)+"|CNAME"; 
    145151  prefix.assign(3*depth, ' '); 
     
    323329 
    324330      bool done=false, realreferral=false, negindic=false; 
    325       string newauth, soaname; 
     331      string newauth, soaname, newtarget; 
    326332 
    327333      for(LWRes::res_t::const_iterator i=result.begin();i!=result.end();++i) { 
     
    333339        } 
    334340        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; 
    336341          ret.push_back(*i); 
    337           set<GetBestNSAnswer>beenthere2; 
    338           return doResolve(i->content, qtype, ret,0,beenthere2); 
     342          newtarget=i->content; 
    339343        } 
    340344        // for ANY answers we *must* have an authoritive answer 
     
    368372        return 0; 
    369373      } 
     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      } 
    370379      else if(realreferral) { 
    371380        cout<<prefix<<qname<<": status=did not resolve, got "<<nsset.size()<<" NS, looping to them"<<endl;