From 80d395efbbd3c95264fd08f7b2745bab6604eeaf Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Fri, 30 Aug 2024 08:58:58 -0600 Subject: [PATCH] output-filedata: use void *initdata instead of OutputCtx Avoids leaking a higher level abstraction into a low level logger. Ticket: #7227 --- src/output-filedata.c | 8 ++++---- src/output-filedata.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/output-filedata.c b/src/output-filedata.c index e3b038d7af..ae6164b8e2 100644 --- a/src/output-filedata.c +++ b/src/output-filedata.c @@ -41,7 +41,7 @@ bool g_filedata_logger_enabled = false; * log module (e.g. http.log) with different output ctx'. */ typedef struct OutputFiledataLogger_ { FiledataLogger LogFunc; - OutputCtx *output_ctx; + void *initdata; struct OutputFiledataLogger_ *next; const char *name; LoggerId logger_id; @@ -52,14 +52,14 @@ typedef struct OutputFiledataLogger_ { static OutputFiledataLogger *list = NULL; int OutputRegisterFiledataLogger(LoggerId id, const char *name, FiledataLogger LogFunc, - OutputCtx *output_ctx, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit) + void *initdata, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit) { OutputFiledataLogger *op = SCCalloc(1, sizeof(*op)); if (op == NULL) return -1; op->LogFunc = LogFunc; - op->output_ctx = output_ctx; + op->initdata = initdata; op->name = name; op->logger_id = id; op->ThreadInit = ThreadInit; @@ -218,7 +218,7 @@ TmEcode OutputFiledataLogThreadInit(ThreadVars *tv, OutputFiledataLoggerThreadDa while (logger) { if (logger->ThreadInit) { void *retptr = NULL; - if (logger->ThreadInit(tv, (void *)logger->output_ctx, &retptr) == TM_ECODE_OK) { + if (logger->ThreadInit(tv, logger->initdata, &retptr) == TM_ECODE_OK) { OutputLoggerThreadStore *ts = SCCalloc(1, sizeof(*ts)); /* todo */ BUG_ON(ts == NULL); diff --git a/src/output-filedata.h b/src/output-filedata.h index 0fb034a9a4..cb0cbcd959 100644 --- a/src/output-filedata.h +++ b/src/output-filedata.h @@ -49,8 +49,8 @@ void OutputFiledataLogFfc(ThreadVars *tv, OutputFiledataLoggerThreadData *td, Pa typedef int (*FiledataLogger)(ThreadVars *, void *thread_data, const Packet *, File *, void *tx, const uint64_t tx_id, const uint8_t *, uint32_t, uint8_t, uint8_t dir); -int OutputRegisterFiledataLogger(LoggerId id, const char *name, FiledataLogger LogFunc, OutputCtx *, - ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit); +int OutputRegisterFiledataLogger(LoggerId id, const char *name, FiledataLogger LogFunc, + void *initdata, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit); void OutputFiledataLoggerRegister(void);