Skip to content

Commit 3e8caad

Browse files
cosmo0920edsiper
authored andcommitted
in_dummy: Use pre_run callback to fix crash path
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 1ba01ff commit 3e8caad

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

plugins/in_dummy/in_dummy.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,6 @@ static int in_dummy_init(struct flb_input_instance *in,
446446

447447
flb_input_set_context(in, ctx);
448448

449-
if (ctx->flush_on_startup) {
450-
in_dummy_collect(in, config, ctx);
451-
}
452-
453449
ret = flb_input_set_collector_time(in,
454450
in_dummy_collect,
455451
tm.tv_sec,
@@ -467,6 +463,20 @@ static int in_dummy_init(struct flb_input_instance *in,
467463
return 0;
468464
}
469465

466+
static int in_dummy_pre_run(struct flb_input_instance *in,
467+
struct flb_config *config, void *in_context)
468+
{
469+
struct flb_dummy *ctx;
470+
471+
ctx = (struct flb_dummy *) in_context;
472+
473+
if (ctx != NULL && ctx->flush_on_startup) {
474+
in_dummy_collect(in, config, in_context);
475+
}
476+
477+
return 0;
478+
}
479+
470480
static void in_dummy_pause(void *data, struct flb_config *config)
471481
{
472482
struct flb_dummy *ctx = data;
@@ -570,7 +580,7 @@ struct flb_input_plugin in_dummy_plugin = {
570580
.name = "dummy",
571581
.description = "Generate dummy data",
572582
.cb_init = in_dummy_init,
573-
.cb_pre_run = NULL,
583+
.cb_pre_run = in_dummy_pre_run,
574584
.cb_collect = in_dummy_collect,
575585
.cb_flush_buf = NULL,
576586
.config_map = config_map,

0 commit comments

Comments
 (0)