From: Bert Hubert Date: Fri, 18 Feb 2005 23:52:08 +0000 (+0000) Subject: remove some more time(0) calls X-Git-Tag: pdns-2.9.18~56 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=87da00e7ac6fcaf63303851bc76e3e88fb0e4ef3;p=pdns remove some more time(0) calls remove outdated and #ifdeffed code s/ogg/off/ git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@324 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 8a7cbd1c9..499f8c75a 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -406,7 +406,7 @@ int main(int argc, char **argv) Utility::srandom(time(0)); arg().set("soa-minimum-ttl","Don't change")="0"; arg().set("soa-serial-offset","Don't change")="0"; - arg().set("no-shuffle","Don't change")="ogg"; + arg().set("no-shuffle","Don't change")="off"; arg().set("aaaa-additional-processing","turn on to do AAAA additional processing (slow)")="off"; arg().set("local-port","port to listen on")="53"; arg().set("local-address","single address to listen on")="0.0.0.0"; diff --git a/pdns/syncres.cc b/pdns/syncres.cc index e9bcd66a8..20e900eba 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -376,7 +376,7 @@ int SyncRes::doResolveAt(set nameservers, string auth, const string &qna } LOG< nameservers, string auth, const string &qna LOG< nameservers, string auth, const string &qna result=d_lwr.result(); if(d_lwr.d_rcode==RCode::ServFail) { LOG< nameservers, string auth, const string &qna } else { LOG< d_last_clean + 60 ) { d_last_clean=now; for(typename cont_t::iterator i=d_cont.begin();i!=d_cont.end();) @@ -46,8 +45,6 @@ public: ++i; } - - typename cont_t::iterator i=d_cont.find(t); if(i==d_cont.end()) return false; @@ -56,10 +53,10 @@ public: return true; } } - void throttle(const Thing& t, unsigned int ttl=0, unsigned int tries=0) + void throttle(time_t now, const Thing& t, unsigned int ttl=0, unsigned int tries=0) { typename cont_t::iterator i=d_cont.find(t); - entry e={ time_t(0)+(ttl ? ttl : d_ttl), tries ? tries : d_limit}; + entry e={ now+(ttl ? ttl : d_ttl), tries ? tries : d_limit}; if(i==d_cont.end()) { d_cont[t]=e; @@ -82,51 +79,6 @@ private: }; -#if 0 - -template class Throttle -{ -public: - Throttle() - { - d_limit=3; - d_ttl=60; - } - bool shouldThrottle(const Thing& t) - { - time_t now=time(0); - while(!d_dq.empty() && d_dq.back().ttd < now) // remove expired entries from the end - d_dq.pop_back(); - - for(typename cont_t::iterator i=d_dq.begin();i!=d_dq.end();++i) - if(i->T==t && i->count-- < 0) - return true; - return false; - } - - void throttle(const Thing& t, unsigned int ttl=0, unsigned int tries=0) - { - entry e; - e.ttd=time(0)+ (ttl ? ttl : d_ttl) ; - e.T=t; - e.count=tries ? tries : d_limit; - d_dq.push_front(e); - - } -private: - int d_limit; - int d_ttl; - struct entry - { - time_t ttd; - Thing T; - int count; - }; - typedef deque cont_t; - cont_t d_dq; -}; -#endif - /** Class that implements a decaying EWMA. This class keeps an exponentially weighted moving average which, additionally, decays over time. The decaying is only done on get.