Changeset 464

Show
Ignore:
Timestamp:
09/01/05 20:35:10 (8 years ago)
Author:
ahu
Message:

make recursor quiet by default
update to 2.9.19-svn version
work on dnsreplay

Location:
trunk/pdns
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/configure.in

    r445 r464  
    11dnl intro 
    22AC_INIT(pdns/receiver.cc) 
    3 AM_INIT_AUTOMAKE(pdns, 2.9.18) 
     3AM_INIT_AUTOMAKE(pdns, 2.9.19-svn) 
    44AC_CANONICAL_HOST 
    55AM_CONFIG_HEADER(config.h) 
  • trunk/pdns/pdns/dnsreplay-mindex.cc

    r462 r464  
    3131#include <set> 
    3232#include <deque> 
     33#include <boost/format.hpp> 
    3334#include <boost/utility.hpp> 
    3435#include <boost/multi_index_container.hpp> 
     
    101102> qids_t; 
    102103                                          
    103  
    104 //typedef map<QuestionIdentifier, shared_ptr<QuestionData> > qids_t; 
    105104qids_t qids; 
    106105 
    107 //typedef map<uint16_t, struct QuestionIdentifier > id2qi_t; 
    108 //id2qi_t id2qi; 
    109  
    110 unsigned int s_questions, s_answers, s_wetimedout, s_perfect, s_mostly, s_origtimedout; 
     106 
     107bool g_throttled; 
     108 
     109unsigned int s_questions, s_origanswers, s_weanswers, s_wetimedout, s_perfect, s_mostly, s_origtimedout; 
    111110unsigned int s_wenever, s_orignever; 
    112111unsigned int s_webetter, s_origbetter, s_norecursionavailable; 
     
    128127 
    129128 
    130 pair<unsigned int, unsigned int> WeOrigSlowQueriesDelta() 
     129void WeOrigSlowQueriesDelta(int& weOutstanding, int& origOutstanding, int& weSlow, int& origSlow) 
    131130{ 
    132131  struct timeval now; 
    133132  gettimeofday(&now, 0); 
    134133 
    135   pair<unsigned int, unsigned int> ret=make_pair(0,0); 
     134  weOutstanding=origOutstanding=weSlow=origSlow=0; 
     135 
    136136  for(qids_t::iterator i=qids.begin(); i!=qids.end(); ++i) { 
    137137    double dt=DiffTime(i->d_resentTime, now); 
    138     if(dt > 2.0) { 
     138    if(dt < 2.0) { 
     139      if(i->d_newRcode == -1)  
     140        weOutstanding++; 
     141      if(i->d_origRcode == -1) 
     142        origOutstanding++; 
     143    } 
     144    else { 
    139145      if(i->d_newRcode == -1) { 
     146        weSlow++; 
    140147        if(!i->d_newlate) { 
    141           //      i->d_newlate=true; // error 
     148          QuestionData qd=*i; 
     149          qd.d_newlate=true; 
     150          qids.replace(i, qd); 
     151 
    142152          s_wetimedout++; 
    143153        } 
    144         ret.first++; 
    145154      } 
    146155      if(i->d_origRcode == -1) { 
     156        origSlow++; 
    147157        if(!i->d_origlate) { 
    148158          QuestionData qd=*i; 
     
    152162          s_origtimedout++; 
    153163        } 
    154         ret.second++; 
    155       } 
    156     } 
    157   } 
    158   return ret; 
     164      } 
     165    } 
     166  } 
    159167} 
    160168 
     
    243251  while(s_socket->recvFromAsync(packet, remote)) { 
    244252    try { 
     253      s_weanswers++; 
    245254      MOADNSParser mdp(packet.c_str(), packet.length()); 
    246255      if(!mdp.d_header.qr) { 
     
    314323void houseKeeping() 
    315324{ 
    316   pair<unsigned int, unsigned int> slows=WeOrigSlowQueriesDelta(); 
     325  static timeval last; 
     326 
     327  struct timeval now; 
     328  gettimeofday(&now, 0); 
     329 
     330  if(DiffTime(last, now) < 0.3) 
     331    return; 
     332 
     333  int weWaitingFor, origWaitingFor, weSlow, origSlow; 
     334  WeOrigSlowQueriesDelta(weWaitingFor, origWaitingFor, weSlow, origSlow); 
    317335     
    318   int waitingFor=qids.size() - slows.first - slows.second; 
    319   if(waitingFor > 1000) { 
    320     cerr<<"Too many questions outstanding, waiting 0.25 seconds"<<endl; 
    321     usleep(250000); 
    322   } 
    323    
    324   cerr<<waitingFor<<" queries that could still come in on time, "<<qids.size()<<" outstanding"<<endl; 
    325    
    326   cerr<<"we late: "<<s_wetimedout<<", orig late: "<< s_origtimedout<<", "<<s_questions<<" questions sent, "<<s_answers 
     336  if(!g_throttled) { 
     337    if( weWaitingFor > 1000) { 
     338      cerr<<"Too many questions ("<<weWaitingFor<<") outstanding, throttling"<<endl; 
     339      g_throttled=true; 
     340    } 
     341  } 
     342  else if(weWaitingFor < 750) { 
     343    cerr<<"Unthrottling ("<<weWaitingFor<<")"<<endl; 
     344    g_throttled=false; 
     345  } 
     346 
     347  if(DiffTime(last, now) < 2) 
     348    return; 
     349 
     350  last=now; 
     351 
     352  /* 
     353        Questions - Pend. - Drop = Answers = (On time + Late) = (Err + Ok) 
     354Orig    9           21      29     36         47        57       66    72 
     355 
     356 
     357   */ 
     358 
     359  format headerfmt   ("%|9t|Questions - Pend. - Drop = Answers = (On time + Late) = (Err + Ok)\n"); 
     360  format datafmt("%s%|9t|%d %|21t|%d %|29t|%d %|36t|%d %|47t|%d %|57t|%d %|66t|%d %|72t|%d\n"); 
     361 
     362   
     363  cerr<<headerfmt; 
     364  cerr<<(datafmt % "Orig"   % s_questions % origWaitingFor  % s_orignever  % s_origanswers % 0 % s_origtimedout  % 0 % 0); 
     365  cerr<<(datafmt % "Refer." % s_questions % weWaitingFor    % s_wenever    % s_weanswers   % 0 % s_wetimedout    % 0 % 0); 
     366 
     367 
     368 
     369  cerr<<weWaitingFor<<" queries that could still come in on time, "<<qids.size()<<" outstanding"<<endl; 
     370   
     371  cerr<<"we late: "<<s_wetimedout<<", orig late: "<< s_origtimedout<<", "<<s_questions<<" questions sent, "<<s_origanswers 
    327372      <<" original answers, "<<s_perfect<<" perfect, "<<s_mostly<<" mostly correct"<<", "<<s_webetter<<" we better, "<<s_origbetter<<" orig better ("<<s_origbetterset.size()<<" diff)"<<endl; 
    328373  cerr<<"we never: "<<s_wenever<<", orig never: "<<s_orignever<<endl; 
     
    398443    } 
    399444    else { 
    400       s_answers++; 
     445      s_origanswers++; 
    401446       
    402447      if(qids.count(qi)) { 
     
    459504  unsigned int once=0; 
    460505  for(;;) { 
    461     if(!((once++)%4000))  
     506    if(!((once++)%100))  
    462507      houseKeeping(); 
    463508 
    464     if(!pr.getUDPPacket()) 
    465       break; 
    466  
    467     sendPacketFromPR(pr, remote); 
     509    if(!g_throttled) { 
     510      if(!pr.getUDPPacket()) 
     511        break; 
     512       
     513      sendPacketFromPR(pr, remote); 
     514    } 
     515    else  
     516      usleep(1000); // move to 'swift poll'  
     517 
    468518    receiveFromReference(); 
    469519  } 
  • trunk/pdns/pdns/pdns_recursor.cc

    r462 r464  
    504504    arg().set("setgid","If set, change group id to this gid for more security")=""; 
    505505    arg().set("setuid","If set, change user id to this uid for more security")=""; 
    506     arg().set("quiet","Suppress logging of questions and answers")="off"; 
     506    arg().set("quiet","Suppress logging of questions and answers")="true"; 
    507507    arg().set("config-dir","Location of configuration directory (recursor.conf)")=SYSCONFDIR; 
    508508    arg().set("socket-dir","Where the controlsocket will live")=LOCALSTATEDIR;