Skip to content

Commit

Permalink
lib: validate engine status on start
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper committed Nov 6, 2017
1 parent 42979e0 commit 24b5868
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/flb_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ flb_ctx_t *flb_create()
}
ctx->config = config;

/* Initialize our pipe to send data to our worker */
/*
* Initialize our pipe to send data to our worker, used
* by 'lib' input plugin.
*/
ret = flb_pipe_create(config->ch_data);
if (ret == -1) {
perror("pipe");
Expand Down Expand Up @@ -381,10 +384,15 @@ int flb_lib_push(flb_ctx_t *ctx, int ffd, void *data, size_t len)

static void flb_lib_worker(void *data)
{
int ret;
struct flb_config *config = data;

flb_log_init(config, FLB_LOG_STDERR, FLB_LOG_INFO, NULL);
flb_engine_start(config);
ret = flb_engine_start(config);
if (ret == -1) {
flb_engine_failed(config);
flb_engine_shutdown(config);
}
}

/* Return the current time to be used by lib callers */
Expand Down Expand Up @@ -427,6 +435,10 @@ int flb_start(flb_ctx_t *ctx)
flb_debug("[lib] backend started");
break;
}
else if (val == FLB_ENGINE_FAILED) {
flb_error("[lib] backend failed");
return -1;
}
}

return 0;
Expand All @@ -437,6 +449,10 @@ int flb_stop(flb_ctx_t *ctx)
{
int ret;

if (!ctx->config) {
return 0;
}

if (ctx->config->file) {
mk_rconf_free(ctx->config->file);
}
Expand Down

0 comments on commit 24b5868

Please sign in to comment.