]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
outputs: call plugin ThreadDeinit, not Deinit
authorJason Ish <jason.ish@oisf.net>
Wed, 1 Nov 2023 22:57:39 +0000 (16:57 -0600)
committerVictor Julien <victor@inliniac.net>
Tue, 14 Nov 2023 18:28:10 +0000 (19:28 +0100)
With the change to the hash table for tracking threaded loggers, this
call is now called once per thread, so should be changed to the
ThreadDeinit, as that is not longer being called.

Then call Deinit for the primary logger. In threaded mode this would be
the parent, its just the logger in non-threaded mode.

Bug: #6438

src/util-logopenfile.c

index edcd9900286e74175eed8091eb7579e38e3762ad..feca63f44afd00e171b6a700144b9def2c027af3 100644 (file)
@@ -865,8 +865,8 @@ int LogFileFreeCtx(LogFileCtx *lf_ctx)
         SCReturnInt(0);
     }
 
-    if (lf_ctx->type == LOGFILE_TYPE_PLUGIN) {
-        lf_ctx->plugin.plugin->Deinit(lf_ctx->plugin.init_data);
+    if (lf_ctx->type == LOGFILE_TYPE_PLUGIN && lf_ctx->parent != NULL) {
+        lf_ctx->plugin.plugin->ThreadDeinit(lf_ctx->plugin.init_data, lf_ctx->plugin.thread_data);
     }
 
     if (lf_ctx->threaded) {
@@ -902,6 +902,13 @@ int LogFileFreeCtx(LogFileCtx *lf_ctx)
         OutputUnregisterFileRotationFlag(&lf_ctx->rotation_flag);
     }
 
+    /* Deinitialize output plugins. We only want to call this for the
+     * parent of threaded output, or always for non-threaded
+     * output. */
+    if (lf_ctx->type == LOGFILE_TYPE_PLUGIN && lf_ctx->parent == NULL) {
+        lf_ctx->plugin.plugin->Deinit(lf_ctx->plugin.init_data);
+    }
+
     memset(lf_ctx, 0, sizeof(*lf_ctx));
     SCFree(lf_ctx);