Changeset 1055

Show
Ignore:
Timestamp:
06/07/07 23:04:09 (1 year ago)
Author:
ahu
Message:

teach zone2sql the 'inode order' trick, plus spruce up reporting a bit, and no longer die on missing files even with --on-error-resume-next

Files:

Legend:

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

    r1018 r1055  
    4242#include "dnsrecords.hh" 
    4343#include <boost/algorithm/string.hpp> 
     44#include <sys/types.h> 
     45#include <sys/stat.h> 
     46#include <unistd.h> 
    4447 
    4548using namespace boost; 
     
    220223    zonefile=arg()["zone"]; 
    221224 
    222     int count=0
     225    int count=0, num_domainsdone=0
    223226 
    224227    if(zonefile.empty()) { 
     
    227230      BP.parse(namedfile.empty() ? "./named.conf" : namedfile); 
    228231     
    229       const vector<BindDomainInfo> &domains=BP.getDomains(); 
     232      vector<BindDomainInfo> domains=BP.getDomains(); 
     233      struct stat st; 
     234      for(vector<BindDomainInfo>::iterator i=domains.begin(); i!=domains.end(); ++i) { 
     235        if(stat(i->filename.c_str(), &st) == 0) { 
     236          i->d_dev = st.st_dev; 
     237          i->d_ino = st.st_ino; 
     238        } 
     239      } 
     240       
     241      sort(domains.begin(), domains.end()); // put stuff in inode order 
    230242 
    231243      int numdomains=domains.size(); 
     
    274286            while(zpt.get(rr))  
    275287              callback(0, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority); 
     288            num_domainsdone++; 
    276289          } 
     290          catch(exception &ae) { 
     291            if(!arg().mustDo("on-error-resume-next")) 
     292              throw; 
     293            else 
     294              cerr<<endl<<ae.what()<<endl; 
     295          } 
     296 
    277297          catch(AhuException &ae) { 
    278298            if(!arg().mustDo("on-error-resume-next")) 
     
    294314      while(zpt.get(rr))  
    295315        callback(0, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority); 
    296  
    297     } 
    298     cerr<<"Parsed "<<num_records<<" records"<<endl
     316      num_domainsdone=1; 
     317    } 
     318    cerr<<num_domainsdone<<" domains were fully parsed, containing "<<num_records<<" records\n"
    299319     
    300320  }