++GITWEB_SITE_HTML_HEAD_STRING++

Jan 28, 2014 Warning: This GIT server is deprecated, we have moved to http://github.com/monkey

Lib: if config->workers is zero, set value based on number of CPU cores
authorEduardo Silva <edsiper@gmail.com>
Thu, 7 Mar 2013 14:23:23 +0000 (08:23 -0600)
committerEduardo Silva <edsiper@gmail.com>
Thu, 7 Mar 2013 14:23:23 +0000 (08:23 -0600)
If the config->workers is zero, the number of worker threads is
determinated based on the number of CPU cores.

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
src/mk_lib.c

index 8caf51d..131bd4b 100644 (file)
@@ -208,6 +208,14 @@ mklib_ctx mklib_init(const char *address, const unsigned int port,
     config->default_mimetype = mk_string_dup(MIMETYPE_DEFAULT_TYPE);
     mk_mimetype_read_config();
 
+    /*
+     * If the worker numbers have not be set, set the number based on
+     * the number of CPU cores
+     */
+    if (config->workers < 1) {
+        config->workers = sysconf(_SC_NPROCESSORS_ONLN);
+    }
+
     config->worker_capacity = mk_server_worker_capacity(config->workers);
     config->max_load = (config->worker_capacity * config->workers);