From: Aurelien DARRAGON Date: Mon, 3 Jul 2023 16:07:30 +0000 (+0200) Subject: MINOR: log: move log-forwarders cleanup in log.c X-Git-Tag: v2.9-dev5~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e187361b5295d04a507c6f8397729ce66ace788b;p=thirdparty%2Fhaproxy.git MINOR: log: move log-forwarders cleanup in log.c Move the log-forwarded proxies cleanup from global deinit() function into log dedicated deinit function. No backport needed. --- diff --git a/src/haproxy.c b/src/haproxy.c index d5c7121d98..1730545ef6 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -2805,16 +2805,9 @@ void deinit(void) free_proxy(p0); }/* end while(p) */ - /* we don't need to free sink_proxies_list proxies since it is - * already handled in sink_deinit() + /* we don't need to free sink_proxies_list nor cfg_log_forward proxies since + * they are respectively cleaned up in sink_deinit() and deinit_log_forward() */ - p = cfg_log_forward; - /* we need to manually clean cfg_log_forward proxy list */ - while (p) { - p0 = p; - p = p->next; - free_proxy(p0); - } /* destroy all referenced defaults proxies */ proxy_destroy_all_unref_defaults(); diff --git a/src/log.c b/src/log.c index 7c626a9655..e8430a88b1 100644 --- a/src/log.c +++ b/src/log.c @@ -1958,6 +1958,20 @@ void deinit_log_buffers() logline_rfc5424 = NULL; } +/* Deinitialize log forwarder proxies used for syslog messages */ +void deinit_log_forward() +{ + struct proxy *p, *p0; + + p = cfg_log_forward; + /* we need to manually clean cfg_log_forward proxy list */ + while (p) { + p0 = p; + p = p->next; + free_proxy(p0); + } +} + /* Builds a log line in based on , and stops before reaching * characters. Returns the size of the output string in characters, * not counting the trailing zero which is always added if the resulting size @@ -3973,6 +3987,8 @@ REGISTER_CONFIG_SECTION("log-forward", cfg_parse_log_forward, NULL); REGISTER_PER_THREAD_ALLOC(init_log_buffers); REGISTER_PER_THREAD_FREE(deinit_log_buffers); +REGISTER_POST_DEINIT(deinit_log_forward); + /* * Local variables: * c-indent-level: 8