-- 
Sonny Karlsson
>From 501889e43748e5ba99798e03ac3d524d4b1b09ec Mon Sep 17 00:00:00 2001
From: Sonny Karlsson <[email protected]>
Date: Mon, 21 Jan 2013 17:33:51 +0100
Subject: [PATCH] config: If Workers is 0, launch one thread per processor.


Signed-off-by: Sonny Karlsson <[email protected]>
---
 lang/en/mconf   |    6 +++---
 src/mk_config.c |    5 ++++-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/lang/en/mconf b/lang/en/mconf
index c4b9879..f0807e4 100644
--- a/lang/en/mconf
+++ b/lang/en/mconf
@@ -29,10 +29,10 @@ cat > conf/monkey.conf <<EOF
     # Monkey launches threads to attend clients; each worker thread is capable
     # of attending more than one client request at one time. The amount of
     # clients that can be handled by each thread is calculated using the
-    # number of file descriptors allowed by the system. This variable cannot
-    # be less than 1.
+    # number of file descriptors allowed by the system. If this variable
+    # is set to 0 monkey will launch one processor per thread.
 
-    Workers 5
+    Workers 0
 
     # Timeout :
     # ---------
diff --git a/src/mk_config.c b/src/mk_config.c
index 4af23b3..aef1d91 100644
--- a/src/mk_config.c
+++ b/src/mk_config.c
@@ -419,7 +419,10 @@ static void mk_config_read_files(char *path_conf, char 
*file_conf)
                                                      "Workers",
                                                      MK_CONFIG_VAL_NUM);
     if (config->workers < 1) {
-        mk_config_print_error_msg("Workers", tmp);
+        config->workers = sysconf(_SC_NPROCESSORS_ONLN);
+        if (config->workers < 1) {
+            mk_config_print_error_msg("Workers", tmp);
+        }
     }
     /* Get each worker clients capacity based on FDs system limits */
     config->worker_capacity = mk_server_worker_capacity(config->workers);
-- 
1.7.10.4

_______________________________________________
Monkey mailing list
[email protected]
http://lists.monkey-project.com/listinfo/monkey

Reply via email to