diff --git a/src/util-logopenfile.c b/src/util-logopenfile.c index edcd9900286e..feca63f44afd 100644 --- a/src/util-logopenfile.c +++ b/src/util-logopenfile.c @@ -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);