Fix numthreads 0 handling.

git-svn-id: file:///svn/unbound/trunk@2482 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2011-08-26 06:50:23 +00:00
parent 39de97e176
commit accc4a6f68
4 changed files with 6 additions and 3 deletions

View file

@ -326,7 +326,7 @@ daemon_create_workers(struct daemon* daemon)
numport = daemon_get_shufport(daemon, shufport);
verbose(VERB_ALGO, "total of %d outgoing ports available", numport);
daemon->num = daemon->cfg->num_threads;
daemon->num = (daemon->cfg->num_threads?daemon->cfg->num_threads:1);
daemon->workers = (struct worker**)calloc((size_t)daemon->num,
sizeof(struct worker*));
for(i=0; i<daemon->num; i++) {

View file

@ -199,7 +199,7 @@ checkrlimits(struct config_file* cfg)
#if !defined(HAVE_PTHREAD) && !defined(HAVE_SOLARIS_THREADS)
int numthread = 1; /* it forks */
#else
int numthread = cfg->num_threads;
int numthread = (cfg->num_threads?cfg->num_threads:1);
#endif
size_t total = numthread * perthread + misc;
size_t avail;

View file

@ -1,3 +1,6 @@
26 August 2011: Wouter
- Fix num-threads 0 does not segfault, reported by Simon Deziel.
24 August 2011: Wouter
- Applied patch from Karel Slany that fixes a memory leak in the
unbound python module, in string conversions.

View file

@ -318,7 +318,7 @@ morechecks(struct config_file* cfg, const char* fname)
if(cfg->verbosity < 0)
fatal_exit("verbosity value < 0");
if(cfg->num_threads < 0 || cfg->num_threads > 10000)
if(cfg->num_threads <= 0 || cfg->num_threads > 10000)
fatal_exit("num_threads value weird");
if(!cfg->do_ip4 && !cfg->do_ip6)
fatal_exit("ip4 and ip6 are both disabled, pointless");