]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Fix numthreads 0 handling.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 26 Aug 2011 06:50:23 +0000 (06:50 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 26 Aug 2011 06:50:23 +0000 (06:50 +0000)
git-svn-id: file:///svn/unbound/trunk@2482 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/daemon.c
daemon/unbound.c
doc/Changelog
smallapp/unbound-checkconf.c

index 9b48ca43967ea75db8f57b87cbf01a910b58036b..5d10acb7128f8732b2c4bb4dd896f2b6401ae15c 100644 (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++) {
index b61fd4f34e8a0e117245ff87c0d804fb9e2184b1..44ad1f5c3315acbd365ae2fd625b4e1fa725cd86 100644 (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;
index c107b413edd27b768c8905a937c0408b9c3a68f2..dd6c1f38c0d0e3cb163a39019c97890b083c5bbf 100644 (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.
index bed13c7da514c46c347d2d8b521e5b5025faef83..8b56f960761a43783e514f7f49c1a62349c0b3ba 100644 (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");