mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 13:51:26 +02:00
MINOR: cfgparse: always alloc idle conns task
The idle conn task is is a global task used to cleanup backend connections marked for deletion. Previously, it was only only allocated if at least one server in the configuration has idle connections. This assumption won't be valid anymore when new servers can be created at runtime with idle connections. Always allocate the global idle conn task.
This commit is contained in:
parent
828adf0121
commit
3efee6572f
@ -1938,6 +1938,7 @@ int check_config_validity()
|
|||||||
char *err;
|
char *err;
|
||||||
struct cfg_postparser *postparser;
|
struct cfg_postparser *postparser;
|
||||||
struct resolvers *curr_resolvers = NULL;
|
struct resolvers *curr_resolvers = NULL;
|
||||||
|
int i;
|
||||||
|
|
||||||
bind_conf = NULL;
|
bind_conf = NULL;
|
||||||
/*
|
/*
|
||||||
@ -2617,7 +2618,8 @@ int check_config_validity()
|
|||||||
LIST_ISEMPTY(&curproxy->uri_auth->http_req_rules))) {
|
LIST_ISEMPTY(&curproxy->uri_auth->http_req_rules))) {
|
||||||
const char *uri_auth_compat_req[10];
|
const char *uri_auth_compat_req[10];
|
||||||
struct act_rule *rule;
|
struct act_rule *rule;
|
||||||
int i = 0;
|
i = 0;
|
||||||
|
|
||||||
/* build the ACL condition from scratch. We're relying on anonymous ACLs for that */
|
/* build the ACL condition from scratch. We're relying on anonymous ACLs for that */
|
||||||
uri_auth_compat_req[i++] = "auth";
|
uri_auth_compat_req[i++] = "auth";
|
||||||
|
|
||||||
@ -3288,8 +3290,6 @@ out_uri_auth_compat:
|
|||||||
|
|
||||||
list_for_each_entry(newsrv, &servers_list, global_list) {
|
list_for_each_entry(newsrv, &servers_list, global_list) {
|
||||||
/* initialize idle conns lists */
|
/* initialize idle conns lists */
|
||||||
int i;
|
|
||||||
|
|
||||||
newsrv->per_thr = calloc(global.nbthread, sizeof(*newsrv->per_thr));
|
newsrv->per_thr = calloc(global.nbthread, sizeof(*newsrv->per_thr));
|
||||||
if (!newsrv->per_thr) {
|
if (!newsrv->per_thr) {
|
||||||
ha_alert("parsing [%s:%d] : failed to allocate per-thread lists for server '%s'.\n",
|
ha_alert("parsing [%s:%d] : failed to allocate per-thread lists for server '%s'.\n",
|
||||||
@ -3306,37 +3306,39 @@ out_uri_auth_compat:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (newsrv->max_idle_conns != 0) {
|
if (newsrv->max_idle_conns != 0) {
|
||||||
if (idle_conn_task == NULL) {
|
|
||||||
idle_conn_task = task_new(MAX_THREADS_MASK);
|
|
||||||
if (!idle_conn_task)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
idle_conn_task->process = srv_cleanup_idle_conns;
|
|
||||||
idle_conn_task->context = NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < global.nbthread; i++) {
|
|
||||||
idle_conns[i].cleanup_task = task_new(1UL << i);
|
|
||||||
if (!idle_conns[i].cleanup_task)
|
|
||||||
goto err;
|
|
||||||
idle_conns[i].cleanup_task->process = srv_cleanup_toremove_conns;
|
|
||||||
idle_conns[i].cleanup_task->context = NULL;
|
|
||||||
HA_SPIN_INIT(&idle_conns[i].idle_conns_lock);
|
|
||||||
MT_LIST_INIT(&idle_conns[i].toremove_conns);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
newsrv->curr_idle_thr = calloc(global.nbthread, sizeof(*newsrv->curr_idle_thr));
|
newsrv->curr_idle_thr = calloc(global.nbthread, sizeof(*newsrv->curr_idle_thr));
|
||||||
if (!newsrv->curr_idle_thr)
|
if (!newsrv->curr_idle_thr) {
|
||||||
goto err;
|
ha_alert("parsing [%s:%d] : failed to allocate idle connection tasks for server '%s'.\n",
|
||||||
continue;
|
newsrv->conf.file, newsrv->conf.line, newsrv->id);
|
||||||
err:
|
cfgerr++;
|
||||||
ha_alert("parsing [%s:%d] : failed to allocate idle connection tasks for server '%s'.\n",
|
continue;
|
||||||
newsrv->conf.file, newsrv->conf.line, newsrv->id);
|
}
|
||||||
cfgerr++;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
idle_conn_task = task_new(MAX_THREADS_MASK);
|
||||||
|
if (!idle_conn_task) {
|
||||||
|
ha_alert("parsing : failed to allocate global idle connection task.\n");
|
||||||
|
cfgerr++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
idle_conn_task->process = srv_cleanup_idle_conns;
|
||||||
|
idle_conn_task->context = NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < global.nbthread; i++) {
|
||||||
|
idle_conns[i].cleanup_task = task_new(1UL << i);
|
||||||
|
if (!idle_conns[i].cleanup_task) {
|
||||||
|
ha_alert("parsing : failed to allocate idle connection tasks for thread '%d'.\n", i);
|
||||||
|
cfgerr++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
idle_conns[i].cleanup_task->process = srv_cleanup_toremove_conns;
|
||||||
|
idle_conns[i].cleanup_task->context = NULL;
|
||||||
|
HA_SPIN_INIT(&idle_conns[i].idle_conns_lock);
|
||||||
|
MT_LIST_INIT(&idle_conns[i].toremove_conns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Check multi-process mode compatibility */
|
/* Check multi-process mode compatibility */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user