From 87f77fa733e0640a83516b5c152efda85c6ec5ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Wed, 25 Sep 2024 19:42:11 +0200 Subject: [PATCH 1/3] threaded-sources: move initial window size calculation to base class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also fixes opentelemetry() and axosyslog-otlp() when workers() > 1, because originally init_window_size was always set to 0 (-1 / num_workers). Signed-off-by: László Várady --- lib/logthrsource/logthrsourcedrv.c | 11 +++++++++-- lib/logthrsource/logthrsourcedrv.h | 2 +- modules/grpc/otel/otel-source.cpp | 2 -- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/logthrsource/logthrsourcedrv.c b/lib/logthrsource/logthrsourcedrv.c index 1920f9b1d9..6817fbd60c 100644 --- a/lib/logthrsource/logthrsourcedrv.c +++ b/lib/logthrsource/logthrsourcedrv.c @@ -108,8 +108,15 @@ log_threaded_source_worker_options_defaults(LogThreadedSourceWorkerOptions *opti void log_threaded_source_worker_options_init(LogThreadedSourceWorkerOptions *options, GlobalConfig *cfg, - const gchar *group_name) + const gchar *group_name, gint num_workers) { + if (options->super.init_window_size == -1) + { + options->super.init_window_size = 100 * num_workers; + } + + options->super.init_window_size /= num_workers; + log_source_options_init(&options->super, cfg, group_name); msg_format_options_init(&options->parse_options, cfg); } @@ -285,7 +292,7 @@ _init_workers(LogThreadedSourceDriver *self) GlobalConfig *cfg = log_pipe_get_config(&self->super.super.super); - log_threaded_source_worker_options_init(&self->worker_options, cfg, self->super.super.group); + log_threaded_source_worker_options_init(&self->worker_options, cfg, self->super.super.group, self->num_workers); for (size_t i = 0; i < self->num_workers; i++) { diff --git a/lib/logthrsource/logthrsourcedrv.h b/lib/logthrsource/logthrsourcedrv.h index 7a44285e99..67baf2a446 100644 --- a/lib/logthrsource/logthrsourcedrv.h +++ b/lib/logthrsource/logthrsourcedrv.h @@ -84,7 +84,7 @@ struct _LogThreadedSourceDriver void log_threaded_source_worker_options_defaults(LogThreadedSourceWorkerOptions *options); void log_threaded_source_worker_options_init(LogThreadedSourceWorkerOptions *options, GlobalConfig *cfg, - const gchar *group_name); + const gchar *group_name, gint num_workers); void log_threaded_source_worker_options_destroy(LogThreadedSourceWorkerOptions *options); void log_threaded_source_driver_set_transport_name(LogThreadedSourceDriver *self, const gchar *transport_name); diff --git a/modules/grpc/otel/otel-source.cpp b/modules/grpc/otel/otel-source.cpp index 3658f9d466..efb6844abd 100644 --- a/modules/grpc/otel/otel-source.cpp +++ b/modules/grpc/otel/otel-source.cpp @@ -116,8 +116,6 @@ syslogng::grpc::otel::SourceDriver::init() msg_info("OpenTelemetry server accepting connections", evt_tag_int("port", port)); - super->super.worker_options.super.init_window_size /= super->super.num_workers; - if (fetch_limit == -1) fetch_limit = super->super.worker_options.super.init_window_size; From e9d7f4379caeebe2065c0487c2c872ca0779841f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Wed, 25 Sep 2024 19:42:30 +0200 Subject: [PATCH 2/3] otel: fix fetch_limit calculation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: László Várady --- modules/grpc/otel/otel-source.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/grpc/otel/otel-source.cpp b/modules/grpc/otel/otel-source.cpp index efb6844abd..f0b8dca06b 100644 --- a/modules/grpc/otel/otel-source.cpp +++ b/modules/grpc/otel/otel-source.cpp @@ -117,7 +117,12 @@ syslogng::grpc::otel::SourceDriver::init() msg_info("OpenTelemetry server accepting connections", evt_tag_int("port", port)); if (fetch_limit == -1) - fetch_limit = super->super.worker_options.super.init_window_size; + { + if (super->super.worker_options.super.init_window_size != -1) + fetch_limit = super->super.worker_options.super.init_window_size / super->super.num_workers; + else + fetch_limit = 100; + } /* * syslog-ng-otlp(): the original HOST is always kept From 9ae0439a0ff7521e57805313a8ca81a124257089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Wed, 25 Sep 2024 19:47:34 +0200 Subject: [PATCH 3/3] news: add bugfix entry for #310 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: László Várady --- news/bugfix-310.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/bugfix-310.md diff --git a/news/bugfix-310.md b/news/bugfix-310.md new file mode 100644 index 0000000000..49305bbd7c --- /dev/null +++ b/news/bugfix-310.md @@ -0,0 +1 @@ +`opentelemetry()`, `axosyslog-otlp()` sources: fix crash when `workers()` is set to `> 1`