From d8042cb3c1f33ccbd50f2572b632d486dfeb2010 Mon Sep 17 00:00:00 2001 From: Christian Hopps Date: Sat, 11 Nov 2023 20:31:13 +0100 Subject: [PATCH] lib: free the log file resources created at startup and config Signed-off-by: Christian Hopps --- lib/log_vty.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/log_vty.c b/lib/log_vty.c index 26e608d16b9b..fc298533aef6 100644 --- a/lib/log_vty.c +++ b/lib/log_vty.c @@ -857,12 +857,24 @@ void log_config_write(struct vty *vty) } } +static int log_vty_fini(void) +{ + if (zt_file_cmdline.filename) + zlog_file_fini(&zt_file_cmdline); + if (zt_file.filename) + zlog_file_fini(&zt_file); + return 0; +} + + static int log_vty_init(const char *progname, const char *protoname, unsigned short instance, uid_t uid, gid_t gid) { zlog_progname = progname; zlog_protoname = protoname; + hook_register(zlog_fini, log_vty_fini); + zlog_set_prefix_ec(true); zlog_set_prefix_xid(true);