Skip to content

Commit

Permalink
input: new function to query collector running status
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper committed Jul 27, 2017
1 parent f88e116 commit 2ea2935
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/fluent-bit/flb_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ int flb_input_set_collector_socket(struct flb_input_instance *in,
void*),
flb_pipefd_t fd,
struct flb_config *config);
int flb_input_collector_running(int coll_id, struct flb_input_instance *in);
void flb_input_initialize_all(struct flb_config *config);
void flb_input_pre_run_all(struct flb_config *config);
void flb_input_exit_all(struct flb_config *config);
Expand Down
19 changes: 17 additions & 2 deletions src/flb_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ int flb_input_set_collector_time(struct flb_input_instance *in,
collector->seconds = seconds;
collector->nanoseconds = nanoseconds;
collector->instance = in;

collector->running = FLB_FALSE;
mk_list_add(&collector->_head, &config->collectors);
mk_list_add(&collector->_head_ins, &in->collectors);

Expand All @@ -476,6 +476,7 @@ int flb_input_set_collector_event(struct flb_input_instance *in,
collector->seconds = -1;
collector->nanoseconds = -1;
collector->instance = in;
collector->running = FLB_FALSE;
mk_list_add(&collector->_head, &config->collectors);
mk_list_add(&collector->_head_ins, &in->collectors);

Expand Down Expand Up @@ -570,6 +571,18 @@ static struct flb_input_collector *get_collector(int id,
return NULL;
}

int flb_input_collector_running(int coll_id, struct flb_input_instance *in)
{
struct flb_input_collector *coll;

coll = get_collector(coll_id, in);
if (!coll) {
return FLB_FALSE;
}

return coll->running;
}

int flb_input_pause_all(struct flb_config *config)
{
int paused = 0;
Expand Down Expand Up @@ -643,7 +656,8 @@ int flb_input_collector_resume(int coll_id, struct flb_input_instance *in)
}

if (coll->running == FLB_TRUE) {
flb_error("[input] cannot resume %s, already running", in->name);
flb_error("[input] cannot resume collector %s:%i, already running",
in->name, coll_id);
return -1;
}

Expand Down Expand Up @@ -692,6 +706,7 @@ int flb_input_set_collector_socket(struct flb_input_instance *in,
collector->seconds = -1;
collector->nanoseconds = -1;
collector->instance = in;
collector->running = FLB_FALSE;
mk_list_add(&collector->_head, &config->collectors);
mk_list_add(&collector->_head_ins, &in->collectors);

Expand Down

0 comments on commit 2ea2935

Please sign in to comment.