]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output/log: Ensure files closed in threaded mode
authorJeff Lucovsky <jeff@lucovsky.org>
Sun, 11 Apr 2021 16:20:15 +0000 (12:20 -0400)
committerVictor Julien <victor@inliniac.net>
Thu, 15 Apr 2021 09:43:29 +0000 (11:43 +0200)
This commit ensures that file objects are closed in threaded mode.

src/util-logopenfile.c

index 102b96e748a0bed18d9c90eb857e180f6cd9222f..b8eee25ed02781fd74ce3a4167cda9b2c43dda4d 100644 (file)
@@ -1,5 +1,5 @@
 /* vi: set et ts=4: */
-/* Copyright (C) 2007-2020 Open Information Security Foundation
+/* Copyright (C) 2007-2021 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -304,6 +304,7 @@ static char *SCLogFilenameFromPattern(const char *pattern)
 
 static void SCLogFileCloseNoLock(LogFileCtx *log_ctx)
 {
+    SCLogDebug("Closing %s", log_ctx->filename);
     if (log_ctx->fp)
         fclose(log_ctx->fp);
 
@@ -821,6 +822,7 @@ int LogFileFreeCtx(LogFileCtx *lf_ctx)
         for(int i = 0; i < lf_ctx->threads->slot_count; i++) {
             if (lf_ctx->threads->lf_slots[i]) {
                 OutputUnregisterFileRotationFlag(&lf_ctx->threads->lf_slots[i]->rotation_flag);
+                lf_ctx->threads->lf_slots[i]->Close(lf_ctx->threads->lf_slots[i]);
                 SCFree(lf_ctx->threads->lf_slots[i]->filename);
                 SCFree(lf_ctx->threads->lf_slots[i]);
             }