Skip to content

Commit

Permalink
filterx: only sync filterx state at filter/parser/rewrite elements an…
Browse files Browse the repository at this point in the history
…d drivers

This patch renames the previous PIF_SYNC_SCOPE to PIF_SYNC_FILTERX as it
better conveys the intent, sync the filterx state (e.g. variables) to
the message _before_ the LogPipe is executed.

I also changed the setup logic so that LogPipe instances do not have the
flag by default, and I explicitly set them for filter/parser/rewrite
elements and drivers (both source and destination).

Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
  • Loading branch information
bazsi committed May 5, 2024
1 parent 9782a80 commit 831316e
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static void
log_driver_init_instance(LogDriver *self, GlobalConfig *cfg)
{
log_pipe_init_instance(&self->super, cfg);
self->super.flags |= PIF_CONFIG_RELATED;
self->super.flags |= PIF_CONFIG_RELATED + PIF_SYNC_FILTERX;
self->super.free_fn = log_driver_free;
self->super.pre_init = log_driver_pre_init_method;
self->super.init = log_driver_init_method;
Expand Down
2 changes: 1 addition & 1 deletion lib/filter/filter-pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ log_filter_pipe_new(FilterExprNode *expr, GlobalConfig *cfg)
LogFilterPipe *self = g_new0(LogFilterPipe, 1);

log_pipe_init_instance(&self->super, cfg);
self->super.flags |= PIF_CONFIG_RELATED;
self->super.flags |= PIF_CONFIG_RELATED + PIF_SYNC_FILTERX;
self->super.init = log_filter_pipe_init;
self->super.queue = log_filter_pipe_queue;
self->super.free_fn = log_filter_pipe_free;
Expand Down
2 changes: 1 addition & 1 deletion lib/filterx/filterx-pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ log_filterx_pipe_new(GList *stmts, GlobalConfig *cfg)
LogFilterXPipe *self = g_new0(LogFilterXPipe, 1);

log_pipe_init_instance(&self->super, cfg);
self->super.flags = (self->super.flags | PIF_CONFIG_RELATED) & ~PIF_SYNC_SCOPE;
self->super.flags = (self->super.flags | PIF_CONFIG_RELATED);
self->super.init = log_filterx_pipe_init;
self->super.queue = log_filterx_pipe_queue;
self->super.free_fn = log_filterx_pipe_free;
Expand Down
1 change: 0 additions & 1 deletion lib/logmpx.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ log_multiplexer_new(GlobalConfig *cfg)
LogMultiplexer *self = g_new0(LogMultiplexer, 1);

log_pipe_init_instance(&self->super, cfg);
self->super.flags = self->super.flags & ~PIF_SYNC_SCOPE;
self->super.init = log_multiplexer_init;
self->super.deinit = log_multiplexer_deinit;
self->super.queue = log_multiplexer_queue;
Expand Down
1 change: 0 additions & 1 deletion lib/logpipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ log_pipe_init_instance(LogPipe *self, GlobalConfig *cfg)
self->queue = NULL;
self->free_fn = log_pipe_free_method;
self->arcs = _arcs;
self->flags = PIF_SYNC_SCOPE;
}

LogPipe *
Expand Down
5 changes: 3 additions & 2 deletions lib/logpipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
/* node created directly by the user */
#define PIF_CONFIG_RELATED 0x0100

#define PIF_SYNC_SCOPE 0x0200
/* sync filterx state and message in right before calling queue() */
#define PIF_SYNC_FILTERX 0x0200

/* private flags range, to be used by other LogPipe instances for their own purposes */

Expand Down Expand Up @@ -458,7 +459,7 @@ log_pipe_queue(LogPipe *s, LogMessage *msg, const LogPathOptions *path_options)
}
}

if ((s->flags & PIF_SYNC_SCOPE))
if ((s->flags & PIF_SYNC_FILTERX))
filterx_eval_sync_message(path_options->filterx_context, &msg, path_options);

if (G_UNLIKELY(s->flags & (PIF_HARD_FLOW_CONTROL | PIF_JUNCTION_END | PIF_CONDITIONAL_MIDPOINT)))
Expand Down
2 changes: 1 addition & 1 deletion lib/parser/parser-expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void
log_parser_init_instance(LogParser *self, GlobalConfig *cfg)
{
log_pipe_init_instance(&self->super, cfg);
self->super.flags |= PIF_CONFIG_RELATED;
self->super.flags |= PIF_CONFIG_RELATED + PIF_SYNC_FILTERX;
self->super.init = log_parser_init_method;
self->super.deinit = log_parser_deinit_method;
self->super.free_fn = log_parser_free_method;
Expand Down
2 changes: 1 addition & 1 deletion lib/rewrite/rewrite-expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ log_rewrite_init_instance(LogRewrite *self, GlobalConfig *cfg)
{
log_pipe_init_instance(&self->super, cfg);
/* indicate that the rewrite rule is changing the message */
self->super.flags |= PIF_CONFIG_RELATED;
self->super.flags |= PIF_CONFIG_RELATED + PIF_SYNC_FILTERX;
self->super.free_fn = log_rewrite_free_method;
self->super.queue = log_rewrite_queue;
self->super.init = log_rewrite_init_method;
Expand Down

0 comments on commit 831316e

Please sign in to comment.