From: Wouter Wijngaards Date: Fri, 26 Aug 2011 06:50:23 +0000 (+0000) Subject: Fix numthreads 0 handling. X-Git-Tag: release-1.4.13rc1~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=accc4a6f68cc2cf61ef910f484a6ec10c5bc941e;p=thirdparty%2Funbound.git Fix numthreads 0 handling. git-svn-id: file:///svn/unbound/trunk@2482 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/daemon/daemon.c b/daemon/daemon.c index 9b48ca439..5d10acb71 100644 --- a/daemon/daemon.c +++ b/daemon/daemon.c @@ -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; inum; i++) { diff --git a/daemon/unbound.c b/daemon/unbound.c index b61fd4f34..44ad1f5c3 100644 --- a/daemon/unbound.c +++ b/daemon/unbound.c @@ -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; diff --git a/doc/Changelog b/doc/Changelog index c107b413e..dd6c1f38c 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -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. diff --git a/smallapp/unbound-checkconf.c b/smallapp/unbound-checkconf.c index bed13c7da..8b56f9607 100644 --- a/smallapp/unbound-checkconf.c +++ b/smallapp/unbound-checkconf.c @@ -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");