--- Begin Message ---
Package: pdns
Severity: wishlist
Tags: patch
Hi pdns maintainers,
the attached dpatch
## DP: Allows multi-index packet cache.
## DP:
## DP: Note that this patch also fixes/worksaround some "C++ programmer
blackouts"
## DP: that should eventually be cleaned up upstream:
## DP: - Works around hilarious "#define L" in header files (effectiveley
breaking boost template includes in our case).
## DP: - Cleans up some C++ namespace issues with boost (most likely due to
lame "use namespace"-things for boost)
## DP: by adding top level namespace "::" where ambigiuous.
is used here (UI) to improve pdns. It applies cleanly to 2.9.21.2-1
after the existing dpatches.
We would be enlightened if you could review it and eventually consider
adding it to the Debian package.
Thanks!
Stephan
-- System Information:
Debian Release: 5.0
APT prefers testing
APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.26-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
#! /bin/sh /usr/share/dpatch/dpatch-run
## ui-25_multi_index.dpatch by Stephan Suerken <[email protected]>
##
## All lines beginning with `## DP:' are a description of the patch.
##
## DP: Allows multi-index packet cache.
## DP:
## DP: Note that this patch also fixes/worksaround some "C++ programmer blackouts"
## DP: that should eventually be cleaned up upstream:
## DP: - Works around hilarious "#define L" in header files (effectiveley breaking boost template includes in our case).
## DP: - Cleans up some C++ namespace issues with boost (most likely due to lame "use namespace"-things for boost)
## DP: by adding top level namespace "::" where ambigiuous.
@DPATCH@
diff -urNad trunk~/pdns/common_startup.cc trunk/pdns/common_startup.cc
--- trunk~/pdns/common_startup.cc 2009-01-05 13:15:46.000000000 +0000
+++ trunk/pdns/common_startup.cc 2009-01-05 13:15:46.000000000 +0000
@@ -105,6 +105,7 @@
arg().set("negquery-cache-ttl","Seconds to store packets in the PacketCache")="60";
arg().set("query-cache-ttl","Seconds to store packets in the PacketCache")="20";
arg().set("soa-minimum-ttl","Default SOA mininum ttl")="3600";
+ arg().set("max-cache-size","Maximum number of queries in PacketCache")="100000";
arg().set("soa-refresh-default","Default SOA refresh")="10800";
arg().set("soa-retry-default","Default SOA retry")="3600";
diff -urNad trunk~/pdns/communicator.cc trunk/pdns/communicator.cc
--- trunk~/pdns/communicator.cc 2009-01-05 13:15:45.000000000 +0000
+++ trunk/pdns/communicator.cc 2009-01-05 13:15:46.000000000 +0000
@@ -196,7 +196,7 @@
void CommunicatorClass::masterUpdateCheck(PacketHandler *P)
{
- if(!arg().mustDo("master"))
+ if(!::arg().mustDo("master"))
return;
UeberBackend *B=dynamic_cast<UeberBackend *>(P->getBackend());
@@ -368,7 +368,7 @@
sin.sin_family = AF_INET;
// Bind to a specific IP (query-local-address) if specified
- string querylocaladdress(arg()["query-local-address"]);
+ string querylocaladdress(::arg()["query-local-address"]);
if (querylocaladdress=="") {
sin.sin_addr.s_addr = INADDR_ANY;
}
@@ -389,7 +389,7 @@
for(;n<10;n++) {
sin.sin_port = htons(10000+(Utility::random()%50000));
- if(bind(d_nsock, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
+ if(::bind(d_nsock, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
break;
}
if(n==10) {
@@ -417,7 +417,7 @@
#endif // WIN32
L<<Logger::Error<<"Master/slave communicator launching"<<endl;
PacketHandler P;
- d_tickinterval=arg().asNum("slave-cycle-interval");
+ d_tickinterval=::arg().asNum("slave-cycle-interval");
makeNotifySocket();
int rc;
diff -urNad trunk~/pdns/packetcache.cc trunk/pdns/packetcache.cc
--- trunk~/pdns/packetcache.cc 2007-04-21 13:56:36.000000000 +0000
+++ trunk/pdns/packetcache.cc 2009-01-05 13:15:46.000000000 +0000
@@ -72,6 +72,7 @@
{
d_ttl=arg().asNum("cache-ttl");
d_recursivettl=arg().asNum("recursive-cache-ttl");
+ d_maxCacheSize=arg().asNum( "max-cache-size" );
d_doRecursion=arg().mustDo("recursor");
}
@@ -107,6 +108,17 @@
if(!ttl)
return;
+#if MULTI
+ cvalue_t val(key, time(0)+ttl, packet);
+
+ TryWriteLock l(&d_mut);
+ if(l.gotIt())
+ {
+ pair<cmap_t::iterator, bool>i(d_map.insert(val));
+ if(i.second==false)
+ d_map.replace(i.first,val);
+ }
+#else
cvalue_t val;
val.ttd=time(0)+ttl;
val.value=packet;
@@ -114,6 +126,7 @@
TryWriteLock l(&d_mut);
if(l.gotIt())
d_map[key]=val;
+#endif
else
S.inc("deferred-cache-inserts");
}
@@ -153,7 +166,11 @@
ReadLock l(&d_mut);
for(cmap_t::iterator i=d_map.begin();i!=d_map.end();++i) {
+#if MULTI
+ string::size_type pos=i->key.find(check);
+#else
string::size_type pos=i->first.find(check);
+#endif
if(!pos || (suffix && pos!=string::npos))
toRemove.push_back(i);
@@ -178,9 +195,15 @@
// needs to do ttl check here
cmap_t::const_iterator i=d_map.find(key);
time_t now=time(0);
+#if MULTI
+ bool ret=(i!=d_map.end() && i->ttd>now);
+ if(ret)
+ content=i->value;
+#else
bool ret=(i!=d_map.end() && i->second.ttd>now);
if(ret)
content=i->second.value;
+#endif
return ret;
}
@@ -192,12 +215,21 @@
memset(counts,0,256*sizeof(counts[0]));
char key;
for(cmap_t::const_iterator i=d_map.begin();i!=d_map.end();++i) {
+#if MULTI
+ if((offset=i->key.find_first_of("|"))==string::npos || offset+1>i->key.size())
+ continue;
+
+ key=i->key[offset+1];
+ if((key=='Q' || key=='q') && !i->value.empty())
+ key='!';
+#else
if((offset=i->first.find_first_of("|"))==string::npos || offset+1>i->first.size())
continue;
key=i->first[offset+1];
if((key=='Q' || key=='q') && !i->second.value.empty())
key='!';
+#endif
counts[(int)key]++;
}
@@ -233,10 +265,22 @@
vector<cmap_t::iterator> toRemove;
+#if MULTI
+ typedef cmap_t::index<tag_ttl>::type ttlsort;
+
+ int cachesize = d_map.size() - d_maxCacheSize;
+ for ( ttlsort::iterator i( d_map.get<tag_ttl>().begin() ); i != d_map.get<tag_ttl>().end() &&
+ ( cachesize > 0 || now>i->ttd ) ; ++i )
+ {
+ --cachesize;
+ toRemove.push_back(d_map.project<0>(i));
+ }
+#else
for(cmap_t::iterator i=d_map.begin();i!=d_map.end();++i) {
if(now>i->second.ttd)
toRemove.push_back(i);
}
+#endif
l.upgrade();
diff -urNad trunk~/pdns/packetcache.hh trunk/pdns/packetcache.hh
--- trunk~/pdns/packetcache.hh 2007-04-21 13:56:36.000000000 +0000
+++ trunk/pdns/packetcache.hh 2009-01-05 13:15:46.000000000 +0000
@@ -23,6 +23,22 @@
#include <utility>
#include <map>
+#define MULTI 1
+
+#if MULTI
+#undef L
+#include <boost/multi_index/ordered_index.hpp>
+#include <boost/multi_index/key_extractors.hpp>
+#include <boost/multi_index_container.hpp>
+#include <boost/version.hpp>
+#include <boost/multi_index/hashed_index.hpp>
+#define L theL()
+
+using namespace ::boost::multi_index;
+struct tag_ttl {};
+
+#endif
+
#ifndef WIN32
# if __GNUC__ >= 3
# include <ext/hash_map>
@@ -73,6 +89,33 @@
void insert(const string &key, const string &packet, unsigned int ttl);
map<char,int> getCounts();
private:
+ void getTTLS();
+
+#if MULTI
+ class CacheContent
+ {
+ public:
+ CacheContent( const string &k, time_t t, const string &v )
+ : key( k )
+ , ttd( t )
+ , value( v )
+ {}
+ string key;
+ time_t ttd;
+ string value;
+ };
+
+ typedef CacheContent cvalue_t;
+
+ typedef multi_index_container<
+ CacheContent,
+ indexed_by <
+ hashed_unique<member<CacheContent,std::string,&CacheContent::key> >,
+ ordered_non_unique<tag<tag_ttl>, member<CacheContent,time_t,&CacheContent::ttd> >
+ >
+ > cmap_t;
+#else
+
typedef string ckey_t;
class CacheContent
@@ -83,7 +126,7 @@
};
typedef CacheContent cvalue_t;
- void getTTLS();
+
#ifndef WIN32
struct compare_string
@@ -109,6 +152,8 @@
#endif // WIN32
+#endif // MULTI
+
cmap_t d_map;
pthread_rwlock_t d_mut;
@@ -118,6 +163,9 @@
int d_miss;
int d_ttl;
int d_recursivettl;
+ cmap_t::size_type d_maxCacheSize;
+ int d_cacheFullDel;
+
bool d_doRecursion;
int *statnumhit;
int *statnummiss;
@@ -179,6 +227,15 @@
cmap_t::const_iterator i;
if((i=d_map.find(key))!=d_map.end()) { // HIT!
+#if MULTI
+ if(i->ttd>time(0)) { // it is still fresh
+ (*statnumhit)++;
+ d_hit++;
+ cached->parse(i->value.c_str(),i->value.size());
+ cached->spoofQuestion(p->qdomain); // for correct case
+ return 1;
+ }
+#else
if(i->second.ttd>time(0)) { // it is still fresh
(*statnumhit)++;
d_hit++;
@@ -186,6 +243,7 @@
cached->spoofQuestion(p->qdomain); // for correct case
return 1;
}
+#endif
}
}
(*statnummiss)++;
diff -urNad trunk~/pdns/pdns.conf-dist trunk/pdns/pdns.conf-dist
--- trunk~/pdns/pdns.conf-dist 2009-01-05 13:15:46.000000000 +0000
+++ trunk/pdns/pdns.conf-dist 2009-01-05 13:15:46.000000000 +0000
@@ -20,6 +20,11 @@
# cache-ttl=20
#################################
+# max-cache-size Maximum number of queries in PacketCache
+#
+# max-cache-size=100000
+
+#################################
# chroot If set, chroot to this directory for more security
#
# chroot=
diff -urNad trunk~/pdns/receiver.cc trunk/pdns/receiver.cc
--- trunk~/pdns/receiver.cc 2008-08-07 07:02:53.000000000 +0000
+++ trunk/pdns/receiver.cc 2009-01-05 13:15:46.000000000 +0000
@@ -123,7 +123,7 @@
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<<getpid()<<endl;
@@ -204,9 +204,9 @@
char **const newargv=new char*[argc+2];
int n;
- if(arg()["config-name"]!="") {
- progname+="-"+arg()["config-name"];
- L<<Logger::Error<<"Virtual configuration name: "<<arg()["config-name"]<<endl;
+ if(::arg()["config-name"]!="") {
+ progname+="-"+::arg()["config-name"];
+ L<<Logger::Error<<"Virtual configuration name: "<<::arg()["config-name"]<<endl;
}
newargv[0]=strdup(const_cast<char *>((progname+"-instance").c_str()));
@@ -321,35 +321,35 @@
static void UNIX_declareArguments()
{
static char pietje[128]="!@@SYSCONFDIR@@:";
- arg().set("config-dir","Location of configuration directory (pdns.conf)")=
+ ::arg().set("config-dir","Location of configuration directory (pdns.conf)")=
strcmp(pietje+1,"@@SYSCONFDIR@@:") ? pietje+strlen("@@SYSCONFDIR@@:")+1 : SYSCONFDIR;
- arg().set("config-name","Name of this virtual configuration - will rename the binary image")="";
- arg().set("socket-dir","Where the controlsocket will live")=LOCALSTATEDIR;
- arg().set("module-dir","Default directory for modules")=LIBDIR;
- arg().set("chroot","If set, chroot to this directory for more security")="";
- arg().set("logging-facility","Log under a specific facility")="";
- arg().set("daemon","Operate as a daemon")="no";
+ ::arg().set("config-name","Name of this virtual configuration - will rename the binary image")="";
+ ::arg().set("socket-dir","Where the controlsocket will live")=LOCALSTATEDIR;
+ ::arg().set("module-dir","Default directory for modules")=LIBDIR;
+ ::arg().set("chroot","If set, chroot to this directory for more security")="";
+ ::arg().set("logging-facility","Log under a specific facility")="";
+ ::arg().set("daemon","Operate as a daemon")="no";
}
static void loadModules()
{
- if(!arg()["load-modules"].empty()) {
+ if(!::arg()["load-modules"].empty()) {
vector<string>modules;
- stringtok(modules,arg()["load-modules"],",");
+ stringtok(modules,::arg()["load-modules"],",");
for(vector<string>::const_iterator i=modules.begin();i!=modules.end();++i) {
bool res;
const string &module=*i;
if(module.find(".")==string::npos)
- res=UeberBackend::loadmodule(arg()["module-dir"]+"/lib"+module+"backend.so");
+ res=UeberBackend::loadmodule(::arg()["module-dir"]+"/lib"+module+"backend.so");
else if(module[0]=='/' || (module[0]=='.' && module[1]=='/') || (module[0]=='.' && module[1]=='.')) // absolute or current path
res=UeberBackend::loadmodule(module);
else
- res=UeberBackend::loadmodule(arg()["module-dir"]+"/"+module);
+ res=UeberBackend::loadmodule(::arg()["module-dir"]+"/"+module);
if(res==false) {
L<<Logger::Error<<"receiver unable to load module "<<module<<endl;
@@ -405,38 +405,38 @@
declareArguments();
UNIX_declareArguments();
- arg().laxParse(argc,argv); // do a lax parse
+ ::arg().laxParse(argc,argv); // do a lax parse
- if(arg()["config-name"]!="")
- s_programname+="-"+arg()["config-name"];
+ if(::arg()["config-name"]!="")
+ s_programname+="-"+::arg()["config-name"];
(void)theL(s_programname);
- string configname=arg()["config-dir"]+"/"+s_programname+".conf";
+ string configname=::arg()["config-dir"]+"/"+s_programname+".conf";
cleanSlashes(configname);
- if(!arg().mustDo("config") && !arg().mustDo("no-config")) // "config" == print a configuration file
- arg().laxFile(configname.c_str());
+ if(!::arg().mustDo("config") && !::arg().mustDo("no-config")) // "config" == print a configuration file
+ ::arg().laxFile(configname.c_str());
- arg().laxParse(argc,argv); // reparse so the commandline still wins
- if(!arg()["logging-facility"].empty()) {
- boost::optional<int> val=logFacilityToLOG(arg().asNum("logging-facility") );
+ ::arg().laxParse(argc,argv); // reparse so the commandline still wins
+ if(!::arg()["logging-facility"].empty()) {
+ boost::optional<int> val=logFacilityToLOG(::arg().asNum("logging-facility") );
if(val)
theL().setFacility(*val);
else
- L<<Logger::Error<<"Unknown logging facility "<<arg().asNum("logging-facility") <<endl;
+ L<<Logger::Error<<"Unknown logging facility "<<::arg().asNum("logging-facility") <<endl;
}
- L.setLoglevel((Logger::Urgency)(arg().asNum("loglevel")));
- L.toConsole((Logger::Urgency)(arg().asNum("loglevel")));
+ L.setLoglevel((Logger::Urgency)(::arg().asNum("loglevel")));
+ L.toConsole((Logger::Urgency)(::arg().asNum("loglevel")));
- if(arg().mustDo("help") || arg().mustDo("config")) {
- arg().set("daemon")="no";
- arg().set("guardian")="no";
+ if(::arg().mustDo("help") || ::arg().mustDo("config")) {
+ ::arg().set("daemon")="no";
+ ::arg().set("guardian")="no";
}
- if(arg().mustDo("guardian") && !isGuarded(argv)) {
- if(arg().mustDo("daemon")) {
+ if(::arg().mustDo("guardian") && !isGuarded(argv)) {
+ if(::arg().mustDo("daemon")) {
L.toConsole(Logger::Critical);
daemonize();
}
@@ -445,7 +445,7 @@
cerr<<"Um, we did get here!"<<endl;
}
- if(arg().mustDo("version")) {
+ if(::arg().mustDo("version")) {
cerr<<"Version: "VERSION", compiled on "<<__DATE__", "__TIME__;
#ifdef __GNUC__
cerr<<" with gcc version "<<__VERSION__;
@@ -457,27 +457,27 @@
// we really need to do work - either standalone or as an instance
loadModules();
- BackendMakers().launch(arg()["launch"]); // vrooooom!
+ BackendMakers().launch(::arg()["launch"]); // vrooooom!
- if(!arg().getCommands().empty()) {
+ if(!::arg().getCommands().empty()) {
cerr<<"Fatal: non-option on the command line, perhaps a '--setting=123' statement missed the '='?"<<endl;
exit(99);
}
- if(arg().mustDo("help")) {
+ if(::arg().mustDo("help")) {
cerr<<"syntax:"<<endl<<endl;
- cerr<<arg().helpstring(arg()["help"])<<endl;
+ cerr<<::arg().helpstring(::arg()["help"])<<endl;
exit(99);
}
- if(arg().mustDo("config")) {
- cout<<arg().configstring()<<endl;
+ if(::arg().mustDo("config")) {
+ cout<<::arg().configstring()<<endl;
exit(99);
}
- if(arg().mustDo("list-modules")) {
+ if(::arg().mustDo("list-modules")) {
vector<string>modules=BackendMakers().getModules();
cerr<<"Modules available:"<<endl;
for(vector<string>::const_iterator i=modules.begin();i!=modules.end();++i)
@@ -486,7 +486,7 @@
exit(99);
}
- if(!arg().asNum("local-port")) {
+ if(!::arg().asNum("local-port")) {
L<<Logger::Error<<"Unable to launch, binding to no port or port 0 makes no sense"<<endl;
exit(99); // this isn't going to fix itself either
}
@@ -494,7 +494,7 @@
L<<Logger::Error<<"Unable to launch, no backends configured for querying"<<endl;
exit(99); // this isn't going to fix itself either
}
- if(arg().mustDo("daemon")) {
+ if(::arg().mustDo("daemon")) {
L.toConsole(Logger::None);
if(!isGuarded(argv))
daemonize();
@@ -507,7 +507,7 @@
else {
L<<Logger::Warning<<"This is a standalone pdns"<<endl;
- if(arg().mustDo("control-console"))
+ if(::arg().mustDo("control-console"))
dl=new DynListener();
else
dl=new DynListener(s_programname);
@@ -530,13 +530,13 @@
// reparse, with error checking
- if(!arg().mustDo("no-config"))
- arg().file(configname.c_str());
- arg().parse(argc,argv);
+ if(!::arg().mustDo("no-config"))
+ ::arg().file(configname.c_str());
+ ::arg().parse(argc,argv);
UeberBackend::go();
N=new UDPNameserver; // this fails when we are not root, throws exception
- if(!arg().mustDo("disable-tcp"))
+ if(!::arg().mustDo("disable-tcp"))
TN=new TCPNameserver;
}
catch(const ArgException &A) {
@@ -563,12 +563,12 @@
mainthread();
}
catch(AhuException &AE) {
- if(!arg().mustDo("daemon"))
+ if(!::arg().mustDo("daemon"))
cerr<<"Exiting because: "<<AE.reason<<endl;
L<<Logger::Error<<"Exiting because: "<<AE.reason<<endl;
}
catch(exception &e) {
- if(!arg().mustDo("daemon"))
+ if(!::arg().mustDo("daemon"))
cerr<<"Exiting because of STL error: "<<e.what()<<endl;
L<<Logger::Error<<"Exiting because of STL error: "<<e.what()<<endl;
}
diff -urNad trunk~/pdns/resolver.cc trunk/pdns/resolver.cc
--- trunk~/pdns/resolver.cc 2009-01-05 13:15:46.000000000 +0000
+++ trunk/pdns/resolver.cc 2009-01-05 13:15:46.000000000 +0000
@@ -60,14 +60,14 @@
memset((char *)&sin,0, sizeof(sin));
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) {
sin.sin_port = htons(10000+(random()%10000));
- if (bind(d_sock, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
+ if (::bind(d_sock, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
break;
}
@@ -203,11 +203,11 @@
throw ResolverException("Unable to make a TCP socket for resolver: "+stringerror());
// Use query-local-address as source IP for queries, if specified.
- string querylocaladdress(arg()["query-local-address"]);
+ string querylocaladdress(::arg()["query-local-address"]);
if (!querylocaladdress.empty()) {
ComboAddress fromaddr(querylocaladdress, 0);
- if (bind(d_sock, (struct sockaddr *)&fromaddr, fromaddr.getSocklen()) < 0) {
+ if (::bind(d_sock, (struct sockaddr *)&fromaddr, fromaddr.getSocklen()) < 0) {
Utility::closesocket(d_sock);
d_sock=-1;
throw ResolverException("Binding to query-local-address: "+stringerror());
@@ -356,7 +356,7 @@
// d_sock is connected and is about to spit out a packet
// FIXED, get and pass max request time
- struct timeval time_left={arg().asNum("max-tcp-request-time"),0};
+ struct timeval time_left={::arg().asNum("max-tcp-request-time"),0};
int len=getLength(time_left);
if(len<0)
throw ResolverException("EOF trying to read axfr chunk from remote TCP client");
diff -urNad trunk~/pdns/tcpreceiver.cc trunk/pdns/tcpreceiver.cc
--- trunk~/pdns/tcpreceiver.cc 2009-01-05 13:15:46.000000000 +0000
+++ trunk/pdns/tcpreceiver.cc 2009-01-05 13:15:46.000000000 +0000
@@ -203,7 +203,7 @@
Utility::setNonBlocking(sock);
ServiceTuple st;
st.port=53;
- parseService(arg()["recursor"],st);
+ parseService(::arg()["recursor"],st);
try {
ComboAddress recursor(st.host, st.port);
@@ -252,7 +252,7 @@
for(;;) {
// FIXED, getting max request value
- struct timeval time_left={arg().asNum("max-tcp-request-time"),0};
+ struct timeval time_left={::arg().asNum("max-tcp-request-time"),0};
ComboAddress remote;
socklen_t remotelen=sizeof(remote);
if(getpeername(fd, (struct sockaddr *)&remote, &remotelen) < 0) {
@@ -351,10 +351,10 @@
bool TCPNameserver::canDoAXFR(shared_ptr<DNSPacket> q)
{
- if(arg().mustDo("disable-axfr"))
+ if(::arg().mustDo("disable-axfr"))
return false;
- if( arg()["allow-axfr-ips"].empty() || d_ng.match( (ComboAddress *) &q->remote ) )
+ if( ::arg()["allow-axfr-ips"].empty() || d_ng.match( (ComboAddress *) &q->remote ) )
return true;
extern CommunicatorClass Communicator;
@@ -452,7 +452,7 @@
int count=0;
int chunk=100; // FIXME: this should probably be autosizing
- if(arg().mustDo("strict-rfc-axfrs"))
+ if(::arg().mustDo("strict-rfc-axfrs"))
chunk=1;
outpacket=shared_ptr<DNSPacket>(q->replyPacket());
@@ -496,15 +496,15 @@
TCPNameserver::TCPNameserver()
{
-// sem_init(&d_connectionroom_sem,0,arg().asNum("max-tcp-connections"));
- d_connectionroom_sem = new Semaphore( arg().asNum( "max-tcp-connections" ));
+// sem_init(&d_connectionroom_sem,0,::arg().asNum("max-tcp-connections"));
+ d_connectionroom_sem = new Semaphore( ::arg().asNum( "max-tcp-connections" ));
- s_timeout=arg().asNum("tcp-idle-timeout");
+ s_timeout=::arg().asNum("tcp-idle-timeout");
vector<string>locals;
- stringtok(locals,arg()["local-address"]," ,");
+ stringtok(locals,::arg()["local-address"]," ,");
vector<string>locals6;
- stringtok(locals6,arg()["local-ipv6"]," ,");
+ stringtok(locals6,::arg()["local-ipv6"]," ,");
if(locals.empty() && locals6.empty())
throw AhuException("No local address specified");
@@ -512,7 +512,7 @@
d_highfd=0;
vector<string> parts;
- stringtok( parts, arg()["allow-axfr-ips"], ", \t" ); // is this IP on the guestlist?
+ stringtok( parts, ::arg()["allow-axfr-ips"], ", \t" ); // is this IP on the guestlist?
for( vector<string>::const_iterator i = parts.begin(); i != parts.end(); ++i ) {
d_ng.addMask( *i );
}
@@ -528,7 +528,7 @@
if(s<0)
throw AhuException("Unable to acquire TCP socket: "+stringerror());
- ComboAddress local(*laddr, arg().asNum("local-port"));
+ ComboAddress local(*laddr, ::arg().asNum("local-port"));
int tmp=1;
if(setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) {
@@ -536,7 +536,7 @@
exit(1);
}
- if(bind(s, (sockaddr*)&local, local.getSocklen())<0) {
+ if(::bind(s, (sockaddr*)&local, local.getSocklen())<0) {
L<<Logger::Error<<"binding to TCP socket: "<<strerror(errno)<<endl;
throw AhuException("Unable to bind to TCP socket");
}
@@ -555,7 +555,7 @@
if(s<0)
throw AhuException("Unable to acquire TCPv6 socket: "+stringerror());
- ComboAddress local(*laddr, arg().asNum("local-port"));
+ ComboAddress local(*laddr, ::arg().asNum("local-port"));
int tmp=1;
if(setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) {
--- End Message ---