From 831316ee4754fec1eea8cd42a02292da0bdf2749 Mon Sep 17 00:00:00 2001 From: Balazs Scheidler Date: Sun, 5 May 2024 19:44:18 +0200 Subject: [PATCH] filterx: only sync filterx state at filter/parser/rewrite elements and 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 --- lib/driver.c | 2 +- lib/filter/filter-pipe.c | 2 +- lib/filterx/filterx-pipe.c | 2 +- lib/logmpx.c | 1 - lib/logpipe.c | 1 - lib/logpipe.h | 5 +++-- lib/parser/parser-expr.c | 2 +- lib/rewrite/rewrite-expr.c | 2 +- 8 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/driver.c b/lib/driver.c index d9cbb36b9e0..7c5a6afb8ee 100644 --- a/lib/driver.c +++ b/lib/driver.c @@ -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; diff --git a/lib/filter/filter-pipe.c b/lib/filter/filter-pipe.c index 7133b943d39..550d42a9f28 100644 --- a/lib/filter/filter-pipe.c +++ b/lib/filter/filter-pipe.c @@ -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; diff --git a/lib/filterx/filterx-pipe.c b/lib/filterx/filterx-pipe.c index 17c7ff3a16d..bc4e185cd7b 100644 --- a/lib/filterx/filterx-pipe.c +++ b/lib/filterx/filterx-pipe.c @@ -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; diff --git a/lib/logmpx.c b/lib/logmpx.c index eb47825351e..2ac1d8397e2 100644 --- a/lib/logmpx.c +++ b/lib/logmpx.c @@ -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; diff --git a/lib/logpipe.c b/lib/logpipe.c index ff2c060392f..202d39f0482 100644 --- a/lib/logpipe.c +++ b/lib/logpipe.c @@ -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 * diff --git a/lib/logpipe.h b/lib/logpipe.h index dc80c1c3bf1..b955be567ca 100644 --- a/lib/logpipe.h +++ b/lib/logpipe.h @@ -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 */ @@ -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))) diff --git a/lib/parser/parser-expr.c b/lib/parser/parser-expr.c index 45340f3a135..5d48852ab9d 100644 --- a/lib/parser/parser-expr.c +++ b/lib/parser/parser-expr.c @@ -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; diff --git a/lib/rewrite/rewrite-expr.c b/lib/rewrite/rewrite-expr.c index 792adbaff38..d696f093390 100644 --- a/lib/rewrite/rewrite-expr.c +++ b/lib/rewrite/rewrite-expr.c @@ -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;