Show
Ignore:
Timestamp:
02/08/10 20:07:25 (3 years ago)
Author:
ahu
Message:

account the packetcached answers in the latency measurement, plus don't clean the nsspeeds cache every 5 seconds (does a full scan!)

Files:
1 modified

Legend:

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

    r1511 r1512  
    831831            if(response.length() >= sizeof(struct dnsheader)) 
    832832              updateRcodeStats(((struct dnsheader*)response.c_str())->rcode); 
     833            g_stats.avgLatencyUsec=(uint64_t)((1-0.0001)*g_stats.avgLatencyUsec + 0); // we assume 0 usec 
    833834            return; 
    834835          } 
     
    10571058{ 
    10581059  static __thread time_t last_stat, last_rootupdate, last_prune; 
     1060  static __thread int cleanCounter=0; 
    10591061  struct timeval now; 
    10601062  Utility::gettimeofday(&now, 0); 
     
    10711073    negcache_by_ttd_index_t::iterator i=ttdindex.lower_bound(now.tv_sec); 
    10721074    ttdindex.erase(ttdindex.begin(), i); 
    1073  
    1074     time_t limit=now.tv_sec-300; 
    1075     for(SyncRes::nsspeeds_t::iterator i = SyncRes::t_sstorage->nsSpeeds.begin() ; i!= SyncRes::t_sstorage->nsSpeeds.end(); ) 
    1076       if(i->second.stale(limit)) 
    1077         SyncRes::t_sstorage->nsSpeeds.erase(i++); 
    1078       else 
    1079         ++i; 
     1075     
     1076    if(!((cleanCounter++)%40)) {  // this is a full scan! 
     1077      time_t limit=now.tv_sec-300; 
     1078      for(SyncRes::nsspeeds_t::iterator i = SyncRes::t_sstorage->nsSpeeds.begin() ; i!= SyncRes::t_sstorage->nsSpeeds.end(); ) 
     1079        if(i->second.stale(limit)) 
     1080          SyncRes::t_sstorage->nsSpeeds.erase(i++); 
     1081        else 
     1082          ++i; 
     1083    } 
    10801084//    L<<Logger::Warning<<"Spent "<<dt.udiff()/1000<<" msec cleaning"<<endl; 
    10811085    last_prune=time(0);