From 9c94a7608f2292c30371a46fcb28e1b027825342 Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Wed, 27 Sep 2023 10:56:18 -0300 Subject: [PATCH] input: initialize flb_input libco parameters using FLB_TLS macros. Signed-off-by: Phillip Whelan --- src/flb_input.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/flb_input.c b/src/flb_input.c index 1c4faad4d3f..3c577cb3709 100644 --- a/src/flb_input.c +++ b/src/flb_input.c @@ -49,8 +49,7 @@ #include #endif /* FLB_HAVE_CHUNK_TRACE */ -struct flb_libco_in_params libco_in_param; -pthread_key_t libco_in_param_key; +FLB_TLS_DEFINE(struct flb_in_collect_params, in_collect_params); #define protcmp(a, b) strncasecmp(a, b, strlen(a)) @@ -141,6 +140,23 @@ int flb_input_log_check(struct flb_input_instance *ins, int l) return FLB_TRUE; } +/* Prepare input co-routines for the thread. */ +void flb_input_prepare() +{ + FLB_TLS_INIT(in_collect_params); +} + +void flb_input_unprepare() +{ + struct flb_in_collect_params *params; + + params = (struct flb_in_collect_params *)FLB_TLS_GET(in_collect_params); + if (params) { + flb_free(params); + FLB_TLS_SET(in_collect_params, NULL); + } +} + /* Create an input plugin instance */ struct flb_input_instance *flb_input_new(struct flb_config *config, const char *input, void *data, @@ -1313,6 +1329,8 @@ void flb_input_exit_all(struct flb_config *config) /* destroy the instance */ flb_input_instance_destroy(ins); } + + flb_input_unprepare(); } /* Check that at least one Input is enabled */