From fd404c4adf990bd8b93f5ff9bb131e89d9bcab21 Mon Sep 17 00:00:00 2001 From: Nicolas Favre-Felix Date: Sat, 9 Apr 2011 13:03:57 +0200 Subject: [PATCH] Configurable pool size. --- conf.c | 3 +++ conf.h | 3 +++ worker.c | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/conf.c b/conf.c index 026716c..9918394 100644 --- a/conf.c +++ b/conf.c @@ -37,6 +37,7 @@ conf_read(const char *filename) { conf->verbosity = WEBDIS_NOTICE; conf->daemonize = 0; conf->database = 0; + conf->pool_size_per_thread = 2; j = json_load_file(filename, 0, &error); if(!j) { @@ -84,6 +85,8 @@ conf_read(const char *filename) { conf->daemonize = 1; } else if(strcmp(json_object_iter_key(kv), "database") == 0 && json_typeof(jtmp) == JSON_INTEGER) { conf->database = json_integer_value(jtmp); + } else if(strcmp(json_object_iter_key(kv), "pool_size") == 0 && json_typeof(jtmp) == JSON_INTEGER) { + conf->pool_size_per_thread = json_integer_value(jtmp); } } diff --git a/conf.h b/conf.h index 02d3484..385149b 100644 --- a/conf.h +++ b/conf.h @@ -16,6 +16,9 @@ struct conf { short http_port; short http_threads; + /* pool size, one pool per worker thread */ + int pool_size_per_thread; + /* daemonize process, off by default */ int daemonize; diff --git a/worker.c b/worker.c index e5dde63..048a2f6 100644 --- a/worker.c +++ b/worker.c @@ -5,6 +5,8 @@ #include "pool.h" #include "slog.h" #include "websocket.h" +#include "conf.h" +#include "server.h" #include #include @@ -25,7 +27,7 @@ worker_new(struct server *s) { (void)ret; /* Redis connection pool */ - w->pool = pool_new(w, 8); /* FIXME: change the number? use conf? */ + w->pool = pool_new(w, s->cfg->pool_size_per_thread); return w;