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 1ad9f039abe71292d88f4f2bd64bc59399e29601
parent 8b20dec0816f97df0ba53ee854ea0bb9b6f0cbc1
Author: Joris Vink <joris@coders.se>
Date:   Fri,  4 Jul 2014 09:14:05 +0200

Add pgsql_conn_max configuration parameter.

Allows you to tune how many pgsql connections kore
will make at one time.

Diffstat:
includes/pgsql.h | 3++-
src/config.c | 34++++++++++++++++++++++++++++++++++
src/kore.c | 7+++++++
src/pgsql.c | 3++-
4 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/includes/pgsql.h b/includes/pgsql.h @@ -26,7 +26,8 @@ struct kore_pgsql { void *conn; }; -extern char *pgsql_conn_string; +extern u_int16_t pgsql_conn_max; +extern char *pgsql_conn_string; void kore_pgsql_init(void); void kore_pgsql_handle(void *, int); diff --git a/src/config.c b/src/config.c @@ -24,6 +24,10 @@ #include "kore.h" #include "http.h" +#if defined(KORE_USE_PGSQL) +#include "pgsql.h" +#endif + /* XXX - This is becoming a clusterfuck. Fix it. */ static int configure_include(char **); @@ -60,6 +64,10 @@ static int configure_authentication_type(char **); static int configure_authentication_value(char **); static int configure_authentication_validator(char **); +#if defined(KORE_USE_PGSQL) +static int configure_pgsql_conn_max(char **); +#endif + static void domain_sslstart(void); static void kore_parse_config_file(char *); @@ -101,6 +109,9 @@ static struct { { "authentication_type", configure_authentication_type }, { "authentication_value", configure_authentication_value }, { "authentication_validator", configure_authentication_validator }, +#if defined(KORE_USE_PGSQL) + { "pgsql_conn_max", configure_pgsql_conn_max }, +#endif { NULL, NULL }, }; @@ -907,3 +918,26 @@ domain_sslstart(void) kore_domain_sslstart(current_domain); current_domain = NULL; } + +#if defined(KORE_USE_PGSQL) + +static int +configure_pgsql_conn_max(char **argv) +{ + int err; + + if (argv[1] == NULL) { + printf("missing parameter for pgsql_conn_max\n"); + return (KORE_RESULT_ERROR); + } + + pgsql_conn_max = kore_strtonum(argv[1], 10, 0, USHRT_MAX, &err); + if (err != KORE_RESULT_OK) { + printf("bad value for pgsql_conn_max: %s\n", argv[1]); + return (KORE_RESULT_ERROR); + } + + return (KORE_RESULT_OK); +} + +#endif diff --git a/src/kore.c b/src/kore.c @@ -246,6 +246,13 @@ kore_server_start(void) kore_write_kore_pid(); kore_log(LOG_NOTICE, "kore is starting up"); +#if defined(KORE_USE_PGSQL) + kore_log(LOG_NOTICE, "pgsql built-in enabled"); +#endif +#if defined(KORE_USE_TASKS) + kore_log(LOG_NOTICE, "tasks built-in enabled"); +#endif + kore_platform_proctitle("kore [parent]"); kore_worker_init(); diff --git a/src/pgsql.c b/src/pgsql.c @@ -53,6 +53,7 @@ static void pgsql_read_result(struct http_request *, int, static TAILQ_HEAD(, pgsql_conn) pgsql_conn_free; static u_int16_t pgsql_conn_count; char *pgsql_conn_string = NULL; +u_int16_t pgsql_conn_max = PGSQL_CONN_MAX; void kore_pgsql_init(void) @@ -73,7 +74,7 @@ kore_pgsql_query(struct http_request *req, char *query, int idx) fatal("kore_pgsql_query: %d already exists", idx); if (TAILQ_EMPTY(&pgsql_conn_free)) { - if (pgsql_conn_count >= PGSQL_CONN_MAX) + if (pgsql_conn_count >= pgsql_conn_max) return (KORE_RESULT_ERROR); }