Skip to content

Commit

Permalink
lib: execute pthread_join only when tid != 0 in flb_stop (backport #9428
Browse files Browse the repository at this point in the history
).

Signed-off-by: Phillip Adair Stewart Whelan <[email protected]>
  • Loading branch information
pwhelan committed Sep 26, 2024
1 parent 315fc06 commit d4438b1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/flb_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,11 +792,17 @@ int flb_stop(flb_ctx_t *ctx)
* There is a chance the worker thread is still active while
* the service exited for some reason (plugin action). Always
* wait and double check that the child thread is not running.
*
* We check the value of tid first to avoid crashes on some
* linux distributions.
*/

if (tid != 0) {
#if defined(FLB_SYSTEM_MACOS)
pthread_cancel(tid);
pthread_cancel(tid);
#endif
pthread_join(tid, NULL);
pthread_join(tid, NULL);
}
return 0;
}

Expand Down

0 comments on commit d4438b1

Please sign in to comment.