From c73c877f7c6478001e9237b28cd88f4af8083237 Mon Sep 17 00:00:00 2001 From: Jesse Rittner Date: Sat, 24 Jul 2021 20:45:48 -0400 Subject: [PATCH] lib: fix race between flb_start and flb_destroy Signed-off-by: Jesse Rittner --- src/flb_lib.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/flb_lib.c b/src/flb_lib.c index 77952119a36..d157c7700b3 100644 --- a/src/flb_lib.c +++ b/src/flb_lib.c @@ -668,6 +668,8 @@ int flb_start(flb_ctx_t *ctx) fd = event->fd; bytes = flb_pipe_r(fd, &val, sizeof(uint64_t)); if (bytes <= 0) { + pthread_cancel(tid); + pthread_join(tid, NULL); ctx->status = FLB_LIB_ERROR; return -1; } @@ -679,6 +681,7 @@ int flb_start(flb_ctx_t *ctx) } else if (val == FLB_ENGINE_FAILED) { flb_error("[lib] backend failed"); + pthread_join(tid, NULL); ctx->status = FLB_LIB_ERROR; return -1; }