Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input: fix crash caused by incorrectly initializing input coroutine params. #7982

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
input: initialize flb_input libco parameters using FLB_TLS macros.
Signed-off-by: Phillip Whelan <phil@calyptia.com>
  • Loading branch information
pwhelan committed Sep 27, 2023
commit 9c94a7608f2292c30371a46fcb28e1b027825342
22 changes: 20 additions & 2 deletions src/flb_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
#include <fluent-bit/flb_chunk_trace.h>
#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))

Expand Down Expand Up @@ -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()
pwhelan marked this conversation as resolved.
Show resolved Hide resolved
{
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,
Expand Down Expand Up @@ -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 */
Expand Down