Skip to content

Commit ff99a74

Browse files
committed
add default for empty value to asNum(), and use a value of 1 for all thread settings in auth
1 parent b81ff68 commit ff99a74

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

pdns/arguments.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ uid_t ArgvMap::asUid(const string &arg)
238238
return uid;
239239
}
240240

241-
int ArgvMap::asNum(const string &arg)
241+
int ArgvMap::asNum(const string &arg, int def)
242242
{
243243
int retval;
244244
const char *cptr_orig;
@@ -247,9 +247,9 @@ int ArgvMap::asNum(const string &arg)
247247
if(!parmIsset(arg))
248248
throw ArgException(string("Undefined but needed argument: '")+arg+"'");
249249

250-
// treat empty values as zeros
250+
// use default for empty values
251251
if (params[arg].empty())
252-
return 0;
252+
return def;
253253

254254
cptr_orig = params[arg].c_str();
255255
retval = static_cast<int>(strtol(cptr_orig, &cptr_ret, 0));

pdns/arguments.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public:
9595
typedef map<string,string> param_t; //!< use this if you need to know the content of the map
9696
bool parmIsset(const string &var); //!< Checks if a parameter is set to *a* value
9797
bool mustDo(const string &var); //!< if a switch is given, if we must do something (--help)
98-
int asNum(const string &var); //!< return a variable value as a number
98+
int asNum(const string &var, int def=0); //!< return a variable value as a number or the default if the variable is empty
9999
mode_t asMode(const string &var); //!< return value interpreted as octal number
100100
uid_t asUid(const string &var); //!< return user id, resolves if necessary
101101
gid_t asGid(const string &var); //!< return group id, resolves if necessary

pdns/common_startup.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ void sendout(const AnswerData<DNSPacket> &AD)
238238
void *qthread(void *number)
239239
{
240240
DNSPacket *P;
241-
DNSDistributor *distributor = DNSDistributor::Create(::arg().asNum("distributor-threads")); // the big dispatcher!
241+
DNSDistributor *distributor = DNSDistributor::Create(::arg().asNum("distributor-threads", 1)); // the big dispatcher!
242242
DNSPacket question;
243243
DNSPacket cached;
244244

@@ -398,7 +398,7 @@ void mainthread()
398398

399399
pthread_create(&qtid,0,carbonDumpThread, 0); // runs even w/o carbon, might change @ runtime
400400
// fork(); (this worked :-))
401-
unsigned int max_rthreads= ::arg().asNum("receiver-threads");
401+
unsigned int max_rthreads= ::arg().asNum("receiver-threads", 1);
402402
for(unsigned int n=0; n < max_rthreads; ++n)
403403
pthread_create(&qtid,0,qthread, reinterpret_cast<void *>(n)); // receives packets
404404

pdns/communicator.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void CommunicatorClass::go()
5858
{
5959
pthread_t tid;
6060
pthread_create(&tid,0,&launchhelper,this); // Starts CommunicatorClass::mainloop()
61-
for(int n=0; n < ::arg().asNum("retrieval-threads"); ++n)
61+
for(int n=0; n < ::arg().asNum("retrieval-threads", 1); ++n)
6262
pthread_create(&tid, 0, &retrieveLaunchhelper, this); // Starts CommunicatorClass::retrievalLoopThread()
6363

6464
d_preventSelfNotification = ::arg().mustDo("prevent-self-notification");

pdns/tcpreceiver.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ int TCPNameserver::doAXFR(const string &target, shared_ptr<DNSPacket> q, int out
609609
trc.d_mac = outpacket->d_trc.d_mac;
610610
outpacket = getFreshAXFRPacket(q);
611611

612-
ChunkedSigningPipe csp(target, securedZone, "", ::arg().asNum("signing-threads"));
612+
ChunkedSigningPipe csp(target, securedZone, "", ::arg().asNum("signing-threads", 1));
613613

614614
typedef map<string, NSECXEntry> nsecxrepo_t;
615615
nsecxrepo_t nsecxrepo;

0 commit comments

Comments
 (0)