From b563ab7460d755c39569e585fea696513dab2bee Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 26 Aug 2026 15:47:54 +0200 Subject: [PATCH] CLEANUP: sink: initialize and finalize the implicit forward proxy sink_new_from_logger() builds a forward proxy by hand from a POST_CHECK hook, that is after check_config_validity() has walked over sink_proxies_list. As a result, contrary to the proxy of a "ring" section, that one was neither passed to proxy_init_per_thr() nor to proxy_finalize(), and kept running with px->per_tgrp left NULL, no load-balancing setup at all (lbprm.algo, lbprm.ops and the lbprm lock were never initialized), and its server left in SRV_ST_STOPPED with a zero effective weight. It still works surprisingly well but for how long... Let's just make sure the freshly created server is completely initialized like any other one so as to avoid susprises in the future like the max-reuse one. This shouldn't be backported as it might reveal other issues in older code. --- src/sink.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/sink.c b/src/sink.c index 8d660ce71..e08a8abfb 100644 --- a/src/sink.c +++ b/src/sink.c @@ -1240,6 +1240,7 @@ struct sink *sink_new_from_logger(struct logger *logger) struct sink *sink = NULL; struct server *srv = NULL; char *err_msg = NULL; + int err_code = ERR_NONE; /* prepare description for the sink */ chunk_reset(&trash); @@ -1293,6 +1294,16 @@ struct sink *sink_new_from_logger(struct logger *logger) if (srv_preinit(srv) & ERR_CODE) goto error; + /* Same thing for the forward proxy: check_config_validity() has + * already walked over sink_proxies_list, so this one is never + * initialized nor finalized. Keep the same order as there, as the + * load-balancing setup performed by proxy_finalize() relies on the + * per-thread-group areas allocated by proxy_init_per_thr(). + */ + proxy_init_per_thr(sink->forward_px); + if (proxy_finalize(sink->forward_px, &err_code) || (err_code & ERR_CODE)) + goto error; + if (sink_finalize(sink) & ERR_CODE) goto error; -- 2.47.3