kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit b0deac577c82df54d9047248fe66ac39b09eed42
parent b035dea3ffbccef8840001f0bb9195017a483c09
Author: Joris Vink <joris@coders.se>
Date:   Mon, 27 Apr 2015 10:36:33 +0200

Add new configuration option: worker_set_affinity.

Controls wether or not worker processes sets its affinity
mask to bind themselves to a single CPU.

Defaults to on (1).

Diffstat:
includes/kore.h | 1+
src/config.c | 19+++++++++++++++++++
src/worker.c | 5++++-
3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/includes/kore.h b/includes/kore.h @@ -358,6 +358,7 @@ extern u_int8_t nlisteners; extern u_int64_t spdy_idle_time; extern u_int16_t cpu_count; extern u_int8_t worker_count; +extern u_int8_t worker_set_affinity; extern u_int32_t worker_rlimit_nofiles; extern u_int32_t worker_max_connections; extern u_int32_t worker_active_connections; diff --git a/src/config.c b/src/config.c @@ -45,6 +45,7 @@ static int configure_certkey(char **); static int configure_rlimit_nofiles(char **); static int configure_max_connections(char **); static int configure_accept_treshold(char **); +static int configure_set_affinity(char **); static int configure_ssl_cipher(char **); static int configure_ssl_dhparam(char **); static int configure_ssl_no_compression(char **); @@ -94,6 +95,7 @@ static struct { { "worker_max_connections", configure_max_connections }, { "worker_rlimit_nofiles", configure_rlimit_nofiles }, { "worker_accept_treshold", configure_accept_treshold }, + { "worker_set_affinity", configure_set_affinity }, { "pidfile", configure_pidfile }, { "accesslog", configure_accesslog }, { "certfile", configure_certfile }, @@ -592,6 +594,23 @@ configure_accept_treshold(char **argv) } static int +configure_set_affinity(char **argv) +{ + int err; + + if (argv[1] == NULL) + return (KORE_RESULT_ERROR); + + worker_set_affinity = kore_strtonum(argv[1], 10, 0, 1, &err); + if (err != KORE_RESULT_OK) { + printf("bad value for worker_set_affinity: %s\n", argv[1]); + return (KORE_RESULT_ERROR); + } + + return (KORE_RESULT_OK); +} + +static int configure_http_header_max(char **argv) { int err; diff --git a/src/worker.c b/src/worker.c @@ -68,6 +68,7 @@ static struct wlock *accept_lock; extern volatile sig_atomic_t sig_recv; struct kore_worker *worker = NULL; struct connection_list worker_clients; +u_int8_t worker_set_affinity = 1; u_int32_t worker_accept_treshold = 0; u_int32_t worker_rlimit_nofiles = 1024; u_int32_t worker_max_connections = 250; @@ -231,7 +232,9 @@ kore_worker_entry(struct kore_worker *kw) (void)snprintf(buf, sizeof(buf), "kore [wrk %d]", kw->id); kore_platform_proctitle(buf); - kore_platform_worker_setcpu(kw); + + if (worker_set_affinity == 1) + kore_platform_worker_setcpu(kw); kore_pid = kw->pid;