From: Amaury Denoyelle Date: Thu, 16 Jul 2026 10:01:02 +0000 (+0200) Subject: MINOR: sink: convert list to standard doubly linked one X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=07dc4cb0ae17c21d63f169cf8211d45fc9ea3523;p=thirdparty%2Fhaproxy.git MINOR: sink: convert list to standard doubly linked one This patch is similar to the previous one, dealing this time with sink proxies stored in . This list is converted to a doubly linked standard list type, in preparation to the conversion of the visible proxies list. The objective is similar : code simplification for check_config_validity() when looping over several proxies list. --- diff --git a/include/haproxy/proxy-t.h b/include/haproxy/proxy-t.h index d6984625b..a5a519069 100644 --- a/include/haproxy/proxy-t.h +++ b/include/haproxy/proxy-t.h @@ -325,6 +325,7 @@ struct proxy { struct list global_list; /* list member for global proxy list */ struct list el; /* attach point in various list * - for log forwarder + * - for sink * - for defaults section */ diff --git a/include/haproxy/sink.h b/include/haproxy/sink.h index 816901b13..9016af0aa 100644 --- a/include/haproxy/sink.h +++ b/include/haproxy/sink.h @@ -28,7 +28,7 @@ extern struct list sink_list; -extern struct proxy *sink_proxies_list; +extern struct list sink_proxies_list; struct sink *sink_find(const char *name); struct sink *sink_find_early(const char *name, const char *from, const char *file, int line); diff --git a/src/cfgparse.c b/src/cfgparse.c index 4c562680d..4c5c3a828 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -2269,7 +2269,7 @@ static struct proxy *_get_next_proxy(void *head, struct proxy *cur) struct proxy *next; struct list *list = (struct list *)head; - if (head == &cfg_log_forward) { + if (head == &cfg_log_forward || head == &sink_proxies_list) { next = cur ? LIST_ELEM(cur->el.n, struct proxy *, el) : LIST_ELEM(list->n, struct proxy *, el); @@ -2503,10 +2503,8 @@ init_proxies_list_stage1: } if (init_proxies_list == &cfg_log_forward) { - init_proxies_list = sink_proxies_list; - /* check if list is not null to avoid infinite loop */ - if (init_proxies_list) - goto init_proxies_list_stage1; + init_proxies_list = &sink_proxies_list; + goto init_proxies_list_stage1; } /***********************************************************/ @@ -2658,10 +2656,8 @@ init_proxies_list_stage2: } if (init_proxies_list == &cfg_log_forward) { - init_proxies_list = sink_proxies_list; - /* check if list is not null to avoid infinite loop */ - if (init_proxies_list) - goto init_proxies_list_stage2; + init_proxies_list = &sink_proxies_list; + goto init_proxies_list_stage2; } /* diff --git a/src/sink.c b/src/sink.c index ec0eb9d46..7fa559a57 100644 --- a/src/sink.c +++ b/src/sink.c @@ -42,7 +42,7 @@ struct list sink_list = LIST_HEAD_INIT(sink_list); /* sink proxies list */ -struct proxy *sink_proxies_list; +struct list sink_proxies_list = LIST_HEAD_INIT(sink_proxies_list); struct sink *cfg_sink; @@ -418,8 +418,7 @@ void sink_setup_proxy(struct proxy *px) px->timeout.connect = TICK_ETERNITY; px->accept = NULL; px->options2 |= PR_O2_INDEPSTR | PR_O2_SMARTCON | PR_O2_SMARTACC; - px->next = sink_proxies_list; - sink_proxies_list = px; + LIST_INSERT(&sink_proxies_list, &px->el); } static void _sink_forward_io_handler(struct appctx *appctx,