]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sink: convert list to standard doubly linked one
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 16 Jul 2026 10:01:02 +0000 (12:01 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 23 Jul 2026 14:03:19 +0000 (16:03 +0200)
This patch is similar to the previous one, dealing this time with sink
proxies stored in <sink_proxies_list>.

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.

include/haproxy/proxy-t.h
include/haproxy/sink.h
src/cfgparse.c
src/sink.c

index d6984625bcc8ea46be4bb415fe9ce7107bee8a28..a5a5190692e94d01f16e264e4fffcd995a2c5527 100644 (file)
@@ -325,6 +325,7 @@ struct proxy {
        struct list global_list;                /* list member for global proxy list */
        struct list el;                         /* attach point in various list
                                                 * - <cfg_log_forward> for log forwarder
+                                                * - <sink_proxies_list> for sink
                                                 * - <defaults_list> for defaults section
                                                 */
 
index 816901b133a3bf1ea58aaf84bcacc57ee137308d..9016af0aa7a5b142b35188d6d36a5947f8d2a89e 100644 (file)
@@ -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);
index 4c562680d647c9a8b9bcd1044c22b8c33a29b816..4c5c3a828b362edbbe272c26d57eeabce207d4b9 100644 (file)
@@ -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;
        }
 
        /*
index ec0eb9d4669d2a9a3aed468b0e8044827d8d8321..7fa559a579b56d285565ec40e678df5d51454646 100644 (file)
@@ -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,