mirror of https://git.kore.io/kore.git
Add pgsql_conn_max configuration parameter.
Allows you to tune how many pgsql connections kore will make at one time.
This commit is contained in:
parent
8b20dec081
commit
1ad9f039ab
|
@ -26,6 +26,7 @@ struct kore_pgsql {
|
||||||
void *conn;
|
void *conn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern u_int16_t pgsql_conn_max;
|
||||||
extern char *pgsql_conn_string;
|
extern char *pgsql_conn_string;
|
||||||
|
|
||||||
void kore_pgsql_init(void);
|
void kore_pgsql_init(void);
|
||||||
|
|
34
src/config.c
34
src/config.c
|
@ -24,6 +24,10 @@
|
||||||
#include "kore.h"
|
#include "kore.h"
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
|
||||||
|
#if defined(KORE_USE_PGSQL)
|
||||||
|
#include "pgsql.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* XXX - This is becoming a clusterfuck. Fix it. */
|
/* XXX - This is becoming a clusterfuck. Fix it. */
|
||||||
|
|
||||||
static int configure_include(char **);
|
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_value(char **);
|
||||||
static int configure_authentication_validator(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 domain_sslstart(void);
|
||||||
static void kore_parse_config_file(char *);
|
static void kore_parse_config_file(char *);
|
||||||
|
|
||||||
|
@ -101,6 +109,9 @@ static struct {
|
||||||
{ "authentication_type", configure_authentication_type },
|
{ "authentication_type", configure_authentication_type },
|
||||||
{ "authentication_value", configure_authentication_value },
|
{ "authentication_value", configure_authentication_value },
|
||||||
{ "authentication_validator", configure_authentication_validator },
|
{ "authentication_validator", configure_authentication_validator },
|
||||||
|
#if defined(KORE_USE_PGSQL)
|
||||||
|
{ "pgsql_conn_max", configure_pgsql_conn_max },
|
||||||
|
#endif
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -907,3 +918,26 @@ domain_sslstart(void)
|
||||||
kore_domain_sslstart(current_domain);
|
kore_domain_sslstart(current_domain);
|
||||||
current_domain = NULL;
|
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
|
||||||
|
|
|
@ -246,6 +246,13 @@ kore_server_start(void)
|
||||||
kore_write_kore_pid();
|
kore_write_kore_pid();
|
||||||
|
|
||||||
kore_log(LOG_NOTICE, "kore is starting up");
|
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_platform_proctitle("kore [parent]");
|
||||||
kore_worker_init();
|
kore_worker_init();
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ static void pgsql_read_result(struct http_request *, int,
|
||||||
static TAILQ_HEAD(, pgsql_conn) pgsql_conn_free;
|
static TAILQ_HEAD(, pgsql_conn) pgsql_conn_free;
|
||||||
static u_int16_t pgsql_conn_count;
|
static u_int16_t pgsql_conn_count;
|
||||||
char *pgsql_conn_string = NULL;
|
char *pgsql_conn_string = NULL;
|
||||||
|
u_int16_t pgsql_conn_max = PGSQL_CONN_MAX;
|
||||||
|
|
||||||
void
|
void
|
||||||
kore_pgsql_init(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);
|
fatal("kore_pgsql_query: %d already exists", idx);
|
||||||
|
|
||||||
if (TAILQ_EMPTY(&pgsql_conn_free)) {
|
if (TAILQ_EMPTY(&pgsql_conn_free)) {
|
||||||
if (pgsql_conn_count >= PGSQL_CONN_MAX)
|
if (pgsql_conn_count >= pgsql_conn_max)
|
||||||
return (KORE_RESULT_ERROR);
|
return (KORE_RESULT_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue