Skip to content

Commit

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

Ticket: OISF#7227
  • Loading branch information
jasonish authored and Corey Thomas committed Sep 3, 2024
1 parent c8ed8ab commit f6a9ce8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/output-streaming.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ typedef struct OutputStreamingLoggerThreadData_ {
* log module (e.g. http.log) with different output ctx'. */
typedef struct OutputStreamingLogger_ {
StreamingLogger LogFunc;
OutputCtx *output_ctx;
void *initdata;
struct OutputStreamingLogger_ *next;
const char *name;
LoggerId logger_id;
Expand All @@ -61,15 +61,15 @@ typedef struct OutputStreamingLogger_ {
static OutputStreamingLogger *list = NULL;

int OutputRegisterStreamingLogger(LoggerId id, const char *name, StreamingLogger LogFunc,
OutputCtx *output_ctx, enum OutputStreamingType type, ThreadInitFunc ThreadInit,
void *initdata, enum OutputStreamingType type, ThreadInitFunc ThreadInit,
ThreadDeinitFunc ThreadDeinit)
{
OutputStreamingLogger *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->type = type;
Expand Down Expand Up @@ -372,7 +372,7 @@ static TmEcode OutputStreamingLogThreadInit(ThreadVars *tv, const void *initdata
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
2 changes: 1 addition & 1 deletion src/output-streaming.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ typedef int (*StreamingLogger)(ThreadVars *, void *thread_data,
uint64_t tx_id, uint8_t flags);

int OutputRegisterStreamingLogger(LoggerId id, const char *name, StreamingLogger LogFunc,
OutputCtx *, enum OutputStreamingType, ThreadInitFunc ThreadInit,
void *initdata, enum OutputStreamingType, ThreadInitFunc ThreadInit,
ThreadDeinitFunc ThreadDeinit);

void OutputStreamingLoggerRegister (void);
Expand Down

0 comments on commit f6a9ce8

Please sign in to comment.