]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
add default for empty value to asNum(), and use a value of 1 for all thread settings... 1518/head
authorKees Monshouwer <mind04@monshouwer.org>
Thu, 12 Jun 2014 22:38:51 +0000 (00:38 +0200)
committermind04 <mind04@monshouwer.org>
Wed, 9 Jul 2014 21:03:22 +0000 (23:03 +0200)
pdns/arguments.cc
pdns/arguments.hh
pdns/common_startup.cc
pdns/communicator.cc
pdns/tcpreceiver.cc

index 9fcc5a0b753de37cd69cc6696d2f9ac86a133021..e5abcdb83419069701c09a20ee656d1affc92c17 100644 (file)
@@ -238,7 +238,7 @@ uid_t ArgvMap::asUid(const string &arg)
    return uid;
 }
 
-int ArgvMap::asNum(const string &arg)
+int ArgvMap::asNum(const string &arg, int def)
 {
   int retval;
   const char *cptr_orig;
@@ -247,9 +247,9 @@ int ArgvMap::asNum(const string &arg)
   if(!parmIsset(arg))
     throw ArgException(string("Undefined but needed argument: '")+arg+"'");
 
-  // treat empty values as zeros
+  // use default for empty values
   if (params[arg].empty())
-   return 0;
+   return def;
 
   cptr_orig = params[arg].c_str();
   retval = static_cast<int>(strtol(cptr_orig, &cptr_ret, 0));
index afd0ede35ee51ff0f27b222dc05497bb681ecd77..a59ebc814797e01a5bfbc726fc97951af58a9582 100644 (file)
@@ -95,7 +95,7 @@ public:
   typedef map<string,string> param_t; //!< use this if you need to know the content of the map
   bool parmIsset(const string &var); //!< Checks if a parameter is set to *a* value
   bool mustDo(const string &var); //!< if a switch is given, if we must do something (--help)
-  int asNum(const string &var); //!< return a variable value as a number
+  int asNum(const string &var, int def=0); //!< return a variable value as a number or the default if the variable is empty
   mode_t asMode(const string &var); //!< return value interpreted as octal number
   uid_t asUid(const string &var); //!< return user id, resolves if necessary
   gid_t asGid(const string &var); //!< return group id, resolves if necessary
index 5bfa4e92c07ba3f973f43663bc182a84f55edc17..bc6599e8804f468bd5a730e9b4800c42517a0c37 100644 (file)
@@ -238,7 +238,7 @@ void sendout(const AnswerData<DNSPacket> &AD)
 void *qthread(void *number)
 {
   DNSPacket *P;
-  DNSDistributor *distributor = DNSDistributor::Create(::arg().asNum("distributor-threads")); // the big dispatcher!
+  DNSDistributor *distributor = DNSDistributor::Create(::arg().asNum("distributor-threads", 1)); // the big dispatcher!
   DNSPacket question;
   DNSPacket cached;
 
@@ -398,7 +398,7 @@ void mainthread()
 
   pthread_create(&qtid,0,carbonDumpThread, 0); // runs even w/o carbon, might change @ runtime    
   //  fork(); (this worked :-))
-  unsigned int max_rthreads= ::arg().asNum("receiver-threads");
+  unsigned int max_rthreads= ::arg().asNum("receiver-threads", 1);
   for(unsigned int n=0; n < max_rthreads; ++n)
     pthread_create(&qtid,0,qthread, reinterpret_cast<void *>(n)); // receives packets
 
index 40aa9e1b5505cca0642b21f13069f3e913d0bea3..41e7e56ca7027d8fcd8b111b2644284e83e0593b 100644 (file)
@@ -58,7 +58,7 @@ void CommunicatorClass::go()
 {
   pthread_t tid;
   pthread_create(&tid,0,&launchhelper,this); // Starts CommunicatorClass::mainloop()
-  for(int n=0; n < ::arg().asNum("retrieval-threads"); ++n)
+  for(int n=0; n < ::arg().asNum("retrieval-threads", 1); ++n)
     pthread_create(&tid, 0, &retrieveLaunchhelper, this); // Starts CommunicatorClass::retrievalLoopThread()
 
   d_preventSelfNotification = ::arg().mustDo("prevent-self-notification");
index 1bfa08215e4fa8512ade2adf5d0165b2f7e5c64f..ccc8d6584a45368c33fc7f8ec6e2e775fbeef58c 100644 (file)
@@ -609,7 +609,7 @@ int TCPNameserver::doAXFR(const string &target, shared_ptr<DNSPacket> q, int out
   trc.d_mac = outpacket->d_trc.d_mac;
   outpacket = getFreshAXFRPacket(q);
   
-  ChunkedSigningPipe csp(target, securedZone, "", ::arg().asNum("signing-threads"));
+  ChunkedSigningPipe csp(target, securedZone, "", ::arg().asNum("signing-threads", 1));
   
   typedef map<string, NSECXEntry> nsecxrepo_t;
   nsecxrepo_t nsecxrepo;