Skip to content

Commit

Permalink
output-filedata: use void *initdata instead of OutputCtx
Browse files Browse the repository at this point in the history
Avoids leaking a higher level abstraction into a low level logger.

Ticket: OISF#7227
  • Loading branch information
jasonish authored and Corey Thomas committed Sep 3, 2024
1 parent f6a9ce8 commit 326779f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/output-filedata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/output-filedata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 326779f

Please sign in to comment.