Permalink
Browse files

add default for empty value to asNum(), and use a value of 1 for all …

…thread settings in auth
  • Loading branch information...
1 parent b81ff68 commit ff99a74bd11359d7fde0b8b0cca42a2980d86a68 @mind04 mind04 committed with mind04 Jun 12, 2014
Showing with 8 additions and 8 deletions.
  1. +3 −3 pdns/arguments.cc
  2. +1 −1 pdns/arguments.hh
  3. +2 −2 pdns/common_startup.cc
  4. +1 −1 pdns/communicator.cc
  5. +1 −1 pdns/tcpreceiver.cc
View
@@ -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));
View
@@ -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
@@ -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
@@ -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");
View
@@ -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;

0 comments on commit ff99a74

Please sign in to comment.