From: Olivier Houchard Date: Thu, 17 Apr 2025 08:42:25 +0000 (+0200) Subject: MINOR: servers: Move the per-thread server initialization earlier X-Git-Tag: v3.2-dev11~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e7613d371746ad908efb7d4f131c52c6de24beff;p=thirdparty%2Fhaproxy.git MINOR: servers: Move the per-thread server initialization earlier Move the code responsible for calling per-thread server initialization earlier than it was done, so that per-thread structures are available a bit later, when we initialize load-balancing. --- diff --git a/src/cfgparse.c b/src/cfgparse.c index b91da359f..d1c850cdc 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -2789,6 +2789,32 @@ int check_config_validity() proxies_list = next; } + /* + * we must finish to initialize certain things on the servers, + * as some of the per_thr/per_tgrp fields may be accessed soon + */ + + MT_LIST_FOR_EACH_ENTRY_LOCKED(newsrv, &servers_list, global_list, back) { + if (srv_init_per_thr(newsrv) == -1) { + ha_alert("parsing [%s:%d] : failed to allocate per-thread lists for server '%s'.\n", + newsrv->conf.file, newsrv->conf.line, newsrv->id); + cfgerr++; + continue; + } + + /* initialize idle conns lists */ + if (newsrv->max_idle_conns != 0) { + newsrv->curr_idle_thr = calloc(global.nbthread, sizeof(*newsrv->curr_idle_thr)); + if (!newsrv->curr_idle_thr) { + ha_alert("parsing [%s:%d] : failed to allocate idle connection tasks for server '%s'.\n", + newsrv->conf.file, newsrv->conf.line, newsrv->id); + cfgerr++; + continue; + } + + } + } + /* starting to initialize the main proxies list */ init_proxies_list = proxies_list; @@ -4142,29 +4168,6 @@ out_uri_auth_compat: /* At this point, target names have already been resolved. */ /***********************************************************/ - /* we must finish to initialize certain things on the servers */ - - MT_LIST_FOR_EACH_ENTRY_LOCKED(newsrv, &servers_list, global_list, back) { - /* initialize idle conns lists */ - if (srv_init_per_thr(newsrv) == -1) { - ha_alert("parsing [%s:%d] : failed to allocate per-thread lists for server '%s'.\n", - newsrv->conf.file, newsrv->conf.line, newsrv->id); - cfgerr++; - continue; - } - - if (newsrv->max_idle_conns != 0) { - newsrv->curr_idle_thr = calloc(global.nbthread, sizeof(*newsrv->curr_idle_thr)); - if (!newsrv->curr_idle_thr) { - ha_alert("parsing [%s:%d] : failed to allocate idle connection tasks for server '%s'.\n", - newsrv->conf.file, newsrv->conf.line, newsrv->id); - cfgerr++; - continue; - } - - } - } - idle_conn_task = task_new_anywhere(); if (!idle_conn_task) { ha_alert("parsing : failed to allocate global idle connection task.\n");