lib: use context status to monitor thread
@@ -481,15 +481,17 @@ int flb_lib_push(flb_ctx_t *ctx, int ffd, const void *data, size_t len)
static void flb_lib_worker(void *data)
{
int ret;
- struct flb_config *config = data;
+ flb_ctx_t *ctx = data;
+ struct flb_config *config;
+ config = ctx->config;
mk_utils_worker_rename("flb-pipeline");
-
ret = flb_engine_start(config);
if (ret == -1) {
flb_engine_failed(config);
flb_engine_shutdown(config);
}
+ ctx->status = FLB_LIB_NONE;
}
/* Return the current time to be used by lib callers */
@@ -515,7 +517,7 @@ int flb_start(flb_ctx_t *ctx)
pthread_once(&flb_lib_once, flb_init_env);
config = ctx->config;
- ret = mk_utils_worker_spawn(flb_lib_worker, config, &tid);
+ ret = mk_utils_worker_spawn(flb_lib_worker, ctx, &tid);
if (ret == -1) {
return -1;
}
@@ -548,7 +550,7 @@ int flb_start(flb_ctx_t *ctx)
int flb_loop(flb_ctx_t *ctx)
{
- while (ctx->config->is_running == FLB_TRUE) {
+ while (ctx->status == FLB_LIB_OK) {
sleep(1);
}
return 0;
