From cfd8fd4e0dcb0275f75d673ad137ac8d48160ee4 Mon Sep 17 00:00:00 2001
From: Oskari Saarenmaa <os@ohmu.fi>
Date: Sat, 4 Aug 2012 00:15:21 +0300
Subject: [PATCH] configuration: one worker per cpu by default.

---
 configuration.c | 3 +++
 stud.8          | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/configuration.c b/configuration.c
index 0e3fd4c..0b7ba12 100644
--- a/configuration.c
+++ b/configuration.c
@@ -124,6 +124,9 @@ stud_config * config_new (void) {
   r->BACK_IP            = strdup("127.0.0.1");
   r->BACK_PORT          = strdup("8000");
   r->NCORES             = 1;
+#ifdef _SC_NPROCESSORS_ONLN
+  r->NCORES             = sysconf(_SC_NPROCESSORS_ONLN);
+#endif
   r->CERT_FILES         = NULL;
   r->CIPHER_SUITE       = NULL;
   r->ENGINE             = NULL;
diff --git a/stud.8 b/stud.8
index bca288a..7f1d20f 100644
--- a/stud.8
+++ b/stud.8
@@ -91,7 +91,7 @@ sent to the backend defined above.
 .It Fl n Ar cores
 Use
 .Ar cores
-worker processes. Default is 1.
+worker processes. Default is the number of CPUs the host has.
 .It Fl B Ar backlog
 Set listen backlog size. Default is 100.
 .It Fl C Ar cache