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.
This commit is contained in:
Aurelien DARRAGON 2023-07-03 18:07:30 +02:00 committed by Christopher Faulet
parent 32f1db6d0d
commit e187361b52
2 changed files with 18 additions and 9 deletions

View File

@ -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();

View File

@ -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 <dst> based on <list_format>, and stops before reaching
* <maxsize> 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