Skip to content
Snippets Groups Projects
Commit d0c0b223 authored by Jan Včelák's avatar Jan Včelák :rocket:
Browse files

config: add option system.background-workers

parent 6c0cf912
Branches
Tags
No related merge requests found
......@@ -117,6 +117,7 @@ update-in { lval.t = yytext; return UPDATE_IN; }
notify-in { lval.t = yytext; return NOTIFY_IN; }
notify-out { lval.t = yytext; return NOTIFY_OUT; }
workers { lval.t = yytext; return WORKERS; }
background-workers { lval.t = yytext; return BACKGROUND_WORKERS; }
user { lval.t = yytext; return USER; }
pidfile { lval.t = yytext; return PIDFILE; }
rundir { lval.t = yytext; return RUNDIR; }
......
......@@ -461,6 +461,7 @@ static void ident_auto(int tok, conf_t *conf, bool val)
%token <tok> MAX_UDP_PAYLOAD
%token <tok> TSIG_ALGO_NAME
%token <tok> WORKERS
%token <tok> BACKGROUND_WORKERS
%token <tok> USER
%token <tok> RUNDIR
%token <tok> PIDFILE
......@@ -590,6 +591,9 @@ system:
| system WORKERS NUM ';' {
SET_NUM(new_config->workers, $3.i, 1, 255, "workers");
}
| system BACKGROUND_WORKERS NUM ';' {
SET_NUM(new_config->bg_workers, $3.i, 1, 255, "background-workers");
}
| system USER TEXT ';' {
new_config->uid = new_config->gid = -1; // Invalidate
char* dpos = strchr($3.t, '.'); // Find uid.gid format
......
......@@ -215,6 +215,7 @@ typedef struct conf_t {
size_t nsid_len;/*!< Server's NSID length. */
size_t max_udp_payload; /*!< Maximal UDP payload size. */
int workers; /*!< Number of workers per interface. */
int bg_workers; /*!< Number of background workers. */
int uid; /*!< Specified user id. */
int gid; /*!< Specified group id. */
int max_conn_idle; /*!< TCP idle timeout. */
......
......@@ -280,7 +280,7 @@ int main(int argc, char **argv)
/* Initialize server. */
server_t server;
res = server_init(&server);
res = server_init(&server, config->bg_workers);
if (res != KNOT_EOK) {
log_server_fatal("Could not initialize server: %s\n",
knot_strerror(res));
......
......@@ -261,7 +261,7 @@ static int reconfigure_sockets(const struct conf_t *conf, server_t *s)
return bound;
}
int server_init(server_t *server)
int server_init(server_t *server, int bg_workers)
{
/* Clear the structure. */
dbg_server("%s(%p)\n", __func__, server);
......@@ -282,8 +282,12 @@ int server_init(server_t *server)
}
/* Create zone events threads. */
#warning TODO: config option
server->workers = worker_pool_create(4); //! \todo config option
if (bg_workers < 1) {
bg_workers = dt_optimal_size();
}
assert(bg_workers > 0);
server->workers = worker_pool_create(bg_workers);
if (server->workers == NULL) {
dt_delete(&server->iosched);
evsched_deinit(&server->sched);
......
......@@ -132,7 +132,7 @@ typedef struct server_t {
* \retval KNOT_EOK on success.
* \retval KNOT_EINVAL on invalid parameters.
*/
int server_init(server_t *server);
int server_init(server_t *server, int bg_workers);
/*!
* \brief Properly destroys the server structure.
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment