Changeset 1108

Show
Ignore:
Timestamp:
11/30/07 23:25:36 (1 year ago)
Author:
ahu
Message:

first 20% speedup of bind backend, possibly much more in setups with a lot of zones

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/pdns/pdns/backends/bind/bindbackend2.cc

    r1089 r1108  
    726726} 
    727727 
    728 bool operator<(const Bind2DNSRecord &a, const string &b) 
    729 { 
    730   return a.qname < b; 
    731 } 
    732  
    733 bool operator<(const string &a, const Bind2DNSRecord &b) 
    734 { 
    735   return a < b.qname; 
    736 } 
    737728 
    738729 
     
    743734  string domain=toLower(qname); 
    744735 
    745   bool mustlog=::arg().mustDo("query-logging"); 
     736  static bool mustlog=::arg().mustDo("query-logging"); 
    746737  if(mustlog)  
    747738    L<<Logger::Warning<<"Lookup for '"<<qtype.getName()<<"' of '"<<domain<<"'"<<endl; 
     
    749740  shared_ptr<State> state = s_state; 
    750741 
    751   while(!state->name_id_map.count(domain) && chopOff(domain)); 
    752  
    753   name_id_map_t::const_iterator iditer=state->name_id_map.find(domain); 
     742  name_id_map_t::const_iterator iditer; 
     743  while((iditer=state->name_id_map.find(domain)) == state->name_id_map.end() && chopOff(domain)) 
     744    ; 
     745 
    754746 
    755747  if(iditer==state->name_id_map.end()) { 
     
    761753  //  unsigned int id=*iditer; 
    762754  if(mustlog) 
    763     L<<Logger::Warning<<"Found data in zone '"<<domain<<"' with id "<<iditer->second<<endl; 
     755    L<<Logger::Warning<<"Found a zone '"<<domain<<"' (with id " << iditer->second<<") that might contain data "<<endl; 
    764756     
    765757  d_handle.id=iditer->second; 
     
    788780  } 
    789781 
    790   d_handle.d_records = state->id_zone_map[iditer->second].d_records; // give it a reference counted copy 
     782  d_handle.d_records = bbd.d_records; // give it a reference counted copy 
    791783   
    792784  if(d_handle.d_records->empty()) 
     
    799791  string lname=toLower(d_handle.qname); 
    800792  range=equal_range(d_handle.d_records->begin(), d_handle.d_records->end(), lname); 
     793  d_handle.mustlog = mustlog; 
    801794   
    802795  if(range.first==range.second) { 
     
    807800    d_handle.d_iter=range.first; 
    808801    d_handle.d_end_iter=range.second; 
    809     d_handle.mustlog = mustlog; 
    810802  } 
    811803 
     
    820812bool Bind2Backend::get(DNSResourceRecord &r) 
    821813{ 
    822   if(!d_handle.d_records) 
     814  if(!d_handle.d_records) { 
     815    if(d_handle.mustlog) 
     816      L<<Logger::Warning<<"There were no answers"<<endl; 
    823817    return false; 
     818  } 
    824819 
    825820  if(!d_handle.get(r)) { 
     821    if(d_handle.mustlog) 
     822      L<<Logger::Warning<<"End of answers"<<endl; 
     823 
    826824    d_handle.reset(); 
    827  
    828     if(::arg().mustDo("query-logging")) 
    829       L<<"End of answers"<<endl; 
    830825 
    831826    return false; 
  • trunk/pdns/pdns/backends/bind/bindbackend2.hh

    r1039 r1108  
    5454    return tie(qtype,content, ttl) < tie(rhs.qtype, rhs.content, rhs.ttl); 
    5555  } 
     56  bool operator<(const string &b) const 
     57  { 
     58    return qname < b; 
     59  } 
    5660}; 
     61 
     62inline bool operator<(const string &a, const Bind2DNSRecord &b) 
     63{ 
     64  return a < b.qname; 
     65} 
    5766 
    5867