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.
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);
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;