From: Bert Hubert Date: Fri, 11 Nov 2005 11:57:50 +0000 (+0000) Subject: big rename, arg() -> ::arg(), bind() -> ::bind() X-Git-Tag: pdns-2.9.20~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e3d8a19046ba72067d2073f7cfd1df65cf463fd;p=thirdparty%2Fpdns.git big rename, arg() -> ::arg(), bind() -> ::bind() remove a read from the configuration from out of the loop - we looked stuff up per packet add pruning of nsspeeds git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@544 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index cfa6c20462..5f4b81dfdd 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -208,7 +208,7 @@ int arecvfrom(char *data, int len, int flags, struct sockaddr *toaddr, Utility:: static void writePid(void) { - string fname=arg()["socket-dir"]+"/"+s_programname+".pid"; + string fname=::arg()["socket-dir"]+"/"+s_programname+".pid"; ofstream of(fname.c_str()); if(of) of<nsset; - if(arg()["hint-file"].empty()) { + if(::arg()["hint-file"].empty()) { static char*ips[]={"198.41.0.4", "192.228.79.201", "192.33.4.12", "128.8.10.90", "192.203.230.10", "192.5.5.241", "192.112.36.4", "128.63.2.53", "192.36.148.17","192.58.128.30", "193.0.14.129", "198.32.64.12", "202.12.27.33"}; DNSResourceRecord arr, nsrr; @@ -245,7 +245,7 @@ void primeHints(void) } } else { - ZoneParserTNG zpt(arg()["hint-file"]); + ZoneParserTNG zpt(::arg()["hint-file"]); DNSResourceRecord rr; set aset; @@ -269,7 +269,7 @@ void primeHints(void) void startDoResolve(void *p) { try { - bool quiet=arg().mustDo("quiet"); + bool quiet=::arg().mustDo("quiet"); DNSComboWriter* dc=(DNSComboWriter *)p; uint16_t maxudpsize=512; @@ -375,15 +375,15 @@ void makeClientSocket() sin.sin_family = AF_INET; - if(!IpToU32(arg()["query-local-address"], &sin.sin_addr.s_addr)) - throw AhuException("Unable to resolve local address '"+ arg()["query-local-address"] +"'"); + if(!IpToU32(::arg()["query-local-address"], &sin.sin_addr.s_addr)) + throw AhuException("Unable to resolve local address '"+ ::arg()["query-local-address"] +"'"); int tries=10; while(--tries) { uint16_t port=10000+Utility::random()%10000; sin.sin_port = htons(port); - if (bind(d_clientsock, (struct sockaddr *)&sin, sizeof(sin)) >= 0) + if (::bind(d_clientsock, (struct sockaddr *)&sin, sizeof(sin)) >= 0) break; } @@ -397,7 +397,7 @@ void makeClientSocket() void makeTCPServerSockets() { vectorlocals; - stringtok(locals,arg()["local-address"]," ,"); + stringtok(locals,::arg()["local-address"]," ,"); if(locals.empty()) throw AhuException("No local address specified"); @@ -420,27 +420,27 @@ void makeTCPServerSockets() exit(1); } - sin.sin_port = htons(arg().asNum("local-port")); + sin.sin_port = htons(::arg().asNum("local-port")); - if (bind(fd, (struct sockaddr *)&sin, sizeof(sin))<0) + if (::bind(fd, (struct sockaddr *)&sin, sizeof(sin))<0) throw AhuException("Binding TCP server socket for "+*i+": "+stringerror()); Utility::setNonBlocking(fd); listen(fd, 128); s_tcpserversocks.push_back(fd); - L<locals; - stringtok(locals,arg()["local-address"]," ,"); + stringtok(locals,::arg()["local-address"]," ,"); if(locals.empty()) throw AhuException("No local address specified"); - if(arg()["local-address"]=="0.0.0.0") { + if(::arg()["local-address"]=="0.0.0.0") { L< 60) { RC.doPrune(); int pruned=0; - for(map::iterator i = SyncRes::s_negcache.begin(); i != SyncRes::s_negcache.end();) + for(SyncRes::negcache_t::iterator i = SyncRes::s_negcache.begin(); i != SyncRes::s_negcache.end();) if(i->second.ttd > now) { SyncRes::s_negcache.erase(i++); pruned++; } else ++i; + + time_t limit=now-300; + for(SyncRes::nsspeeds_t::iterator i = SyncRes::s_nsSpeeds.begin() ; i!= SyncRes::s_nsSpeeds.end(); ) + if(i->second.stale(limit)) + SyncRes::s_nsSpeeds.erase(i++); + else + ++i; + // cerr<<"Pruned "< tcpconnections; counter=0; time_t now=0; - unsigned int maxTcpClients=arg().asNum("max-tcp-clients"); + unsigned int maxTcpClients=::arg().asNum("max-tcp-clients"); + int tcpLimit=::arg().asNum("client-tcp-timeout"); for(;;) { while(MT->schedule()); // housekeeping, let threads do their thing @@ -731,7 +741,7 @@ int main(int argc, char **argv) now=time(0); vector sweeped; - int tcpLimit=arg().asNum("client-tcp-timeout"); + for(vector::iterator i=tcpconnections.begin();i!=tcpconnections.end();++i) { if(now < i->startTime + tcpLimit) { FD_SET(i->fd, &readfds);