From: Willy Tarreau Date: Sat, 23 Aug 2025 17:33:52 +0000 (+0200) Subject: MINOR: server: add server_index_id() to index a server by its ID X-Git-Tag: v3.3-dev9~100 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5a5cec4d7a3510676955b322254b46369f5f54d0;p=thirdparty%2Fhaproxy.git MINOR: server: add server_index_id() to index a server by its ID This avoids needlessly exposing the tree's root and the mechanics outside of the low-level code. --- diff --git a/include/haproxy/server.h b/include/haproxy/server.h index ad9036109..606c1f4e8 100644 --- a/include/haproxy/server.h +++ b/include/haproxy/server.h @@ -196,6 +196,12 @@ static inline void srv_free(struct server **srv_ptr) *srv_ptr = NULL; } +/* index server 's id into proxy 's used_server_id */ +static inline void server_index_id(struct proxy *px, struct server *srv) +{ + eb32_insert(&px->conf.used_server_id, &srv->conf.id); +} + /* increase the number of cumulated streams on the designated server */ static inline void srv_inc_sess_ctr(struct server *s) { diff --git a/src/cfgparse.c b/src/cfgparse.c index b9806bd46..b03628a06 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -3728,7 +3728,7 @@ out_uri_auth_compat: */ next_id = server_get_next_id(curproxy, next_id); newsrv->conf.id.key = newsrv->puid = next_id; - eb32_insert(&curproxy->conf.used_server_id, &newsrv->conf.id); + server_index_id(curproxy, newsrv); } next_id++; diff --git a/src/server.c b/src/server.c index a473b56a5..94b76917a 100644 --- a/src/server.c +++ b/src/server.c @@ -4017,7 +4017,7 @@ int parse_server(const char *file, int linenum, char **args, * check_config_validity. */ if (newsrv->flags & SRV_F_FORCED_ID) - eb32_insert(&curproxy->conf.used_server_id, &newsrv->conf.id); + server_index_id(curproxy, newsrv); HA_DIAG_WARNING_COND((curproxy->cap & PR_CAP_LB) && !newsrv->uweight, "configured with weight of 0 will never be selected by load balancing algorithms\n"); @@ -6254,7 +6254,7 @@ static int cli_parse_add_server(char **args, char *payload, struct appctx *appct } /* insert the server in the backend trees */ - eb32_insert(&be->conf.used_server_id, &srv->conf.id); + server_index_id(be, srv); cebis_item_insert(&be->conf.used_server_name, conf.name_node, id, srv); /* addr_key could be NULL if FQDN resolution is postponed (ie: add server from cli) */ if (srv->addr_key)