Show
Ignore:
Timestamp:
02/19/07 22:04:32 (6 years ago)
Author:
ahu
Message:

implement 'forward-zones-file' for large amounts of forwarded zones, remove TSC manipulation code from default compilation, disable speedups that sometimes caused problems

Files:
1 modified

Legend:

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

    r955 r963  
    820820  ComboAddress fromaddr; 
    821821  socklen_t addrlen=sizeof(fromaddr); 
    822   uint64_t tsc1, tsc2; 
     822  //  uint64_t tsc1, tsc2; 
    823823 
    824824  if((len=recvfrom(fd, data, sizeof(data), 0, (sockaddr *)&fromaddr, &addrlen)) >= 0) { 
    825     RDTSC(tsc1);       
     825    //    RDTSC(tsc1);       
    826826    g_stats.addRemote(fromaddr); 
    827827 
     
    842842      else { 
    843843        ++g_stats.qcounter; 
     844#if 0 
    844845        uint16_t type; 
    845846        char qname[256]; 
     
    893894        } 
    894895      slow: 
     896#endif 
    895897        DNSComboWriter* dc = new DNSComboWriter(data, len, g_now); 
    896898        dc->setSocket(fd); 
     
    14821484  } 
    14831485   
     1486  if(!::arg()["forward-zones-file"].empty()) { 
     1487    L<<Logger::Warning<<"Reading zone forwarding information from '"<<::arg()["forward-zones-file"]<<"'"<<endl; 
     1488    SyncRes::AuthDomain ad; 
     1489    FILE *rfp=fopen(::arg()["forward-zones-file"].c_str(), "r"); 
     1490 
     1491    if(!rfp) 
     1492      throw AhuException("Error opening forward-zones-file '"+::arg()["forward-zones-file"]+"': "+stringerror()); 
     1493 
     1494    shared_ptr<FILE> fp=shared_ptr<FILE>(rfp, fclose); 
     1495     
     1496    char line[1024]; 
     1497    vector<string> parts; 
     1498    int linenum=0; 
     1499    uint64_t before = SyncRes::s_domainmap.size(); 
     1500    while(linenum++, fgets(line, sizeof(line)-1, fp.get())) { 
     1501      parts.clear(); 
     1502      stringtok(parts,line,"=, "); 
     1503      if(parts.empty()) 
     1504        continue; 
     1505      if(parts.size()<2)  
     1506        throw AhuException("Error parsing line "+lexical_cast<string>(linenum)+" of " +::arg()["forward-zones-file"]); 
     1507      trim(parts[0]); 
     1508      trim(parts[1]); 
     1509      parts[0]=toCanonic("", parts[0]); 
     1510      ad.d_server=parts[1]; 
     1511      //      cerr<<"Inserting '"<<domain<<"' to '"<<ad.d_server<<"'\n"; 
     1512      SyncRes::s_domainmap[parts[0]]=ad; 
     1513    } 
     1514    L<<Logger::Warning<<"Done parsing " << SyncRes::s_domainmap.size() - before<<" forwarding instructions"<<endl; 
     1515  } 
     1516 
    14841517  if(::arg().mustDo("export-etc-hosts")) { 
    14851518    string line; 
     
    16071640    SyncRes::s_serverID=tmp; 
    16081641  } 
    1609    
    16101642   
    16111643  parseAuthAndForwards(); 
     
    18021834    ::arg().set("auth-zones", "Zones for which we have authoritative data, comma separated domain=file pairs ")=""; 
    18031835    ::arg().set("forward-zones", "Zones for which we forward queries, comma separated domain=ip pairs")=""; 
     1836    ::arg().set("forward-zones-file", "File with domain=ip pairs for forwarding")=""; 
    18041837    ::arg().set("export-etc-hosts", "If we should serve up contents from /etc/hosts")="off"; 
    18051838    ::arg().set("serve-rfc1918", "If we should be authoritative for RFC 1918 private IP space")="";