]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
log: Ensure threaded eve honors SIGHUP
authorJeff Lucovsky <jeff@lucovsky.org>
Tue, 8 Sep 2020 12:26:36 +0000 (08:26 -0400)
committerVictor Julien <victor@inliniac.net>
Thu, 10 Sep 2020 18:41:12 +0000 (20:41 +0200)
This commit ensures that all logging contexts register for the file
rotation mechanism (SIGHUP and configured).

src/util-logopenfile.c

index 1c1c4e4bdca864a826283100e1d4617e08dac7b4..3eb6566aba884618dd92a3c4dfea8f0ad3ccec4c 100644 (file)
@@ -736,8 +736,10 @@ static bool LogFileNewThreadedCtx(LogFileCtx *parent_ctx, const char *log_path,
     thread->threaded = false;
     thread->parent = parent_ctx;
     thread->id = thread_id;
+    thread->is_regular = true;
     thread->Write = SCLogFileWriteNoLock;
     thread->Close = SCLogFileCloseNoLock;
+    OutputRegisterFileRotationFlag(&thread->rotation_flag);
 
     parent_ctx->threads->lf_slots[thread_id] = thread;
     return true;
@@ -767,6 +769,7 @@ int LogFileFreeCtx(LogFileCtx *lf_ctx)
         SCMutexDestroy(&lf_ctx->threads->mutex);
         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);
                 SCFree(lf_ctx->threads->lf_slots[i]->filename);
                 SCFree(lf_ctx->threads->lf_slots[i]);
             }
@@ -801,7 +804,9 @@ int LogFileFreeCtx(LogFileCtx *lf_ctx)
     if (lf_ctx->sensor_name)
         SCFree(lf_ctx->sensor_name);
 
-    OutputUnregisterFileRotationFlag(&lf_ctx->rotation_flag);
+    if (!lf_ctx->threaded) {
+        OutputUnregisterFileRotationFlag(&lf_ctx->rotation_flag);
+    }
 
     SCFree(lf_ctx);