Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

processor: input: output: organize initialization sequence for processor #7396

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/flb_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,12 @@ int flb_input_init_all(struct flb_config *config)
flb_input_instance_destroy(ins);
return -1;
}

cosmo0920 marked this conversation as resolved.
Show resolved Hide resolved
/* initialize processors */
ret = flb_processor_init(ins->processor);
if (ret == -1) {
return -1;
}
}

return 0;
Expand Down
6 changes: 6 additions & 0 deletions src/flb_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,12 @@ int flb_output_init_all(struct flb_config *config)
flb_output_name(ins));
return -1;
}

/* initialize processors */
ret = flb_processor_init(ins->processor);
if (ret == -1) {
return -1;
}
}

return 0;
Expand Down
16 changes: 10 additions & 6 deletions src/flb_processor.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ static int load_from_config_format_group(struct flb_processor *proc, int type, s
struct cfl_kvpair *pair = NULL;
struct cfl_list *head;
struct flb_processor_unit *pu;
struct flb_filter_instance *f_ins;

if (val->type != CFL_VARIANT_ARRAY) {
return -1;
Expand Down Expand Up @@ -566,6 +567,15 @@ static int load_from_config_format_group(struct flb_processor *proc, int type, s
if (pair->val->type != CFL_VARIANT_STRING) {
continue;
}
/* If filter plugin in processor unit has its own match rule,
* we must release the pre-allocated '*' match at first.
*/
if (pu->unit_type == FLB_PROCESSOR_UNIT_FILTER) {
if (strcmp(pair->key, "match") == 0) {
f_ins = (struct flb_filter_instance *)pu->ctx;
flb_sds_destroy(f_ins->match);
leonardo-albertovich marked this conversation as resolved.
Show resolved Hide resolved
}
}

ret = flb_processor_unit_set_property(pu, pair->key, pair->val->data.as_string);
if (ret == -1) {
Expand Down Expand Up @@ -615,12 +625,6 @@ int flb_processors_load_from_config_format_group(struct flb_processor *proc, str
}
}

/* initialize processors */
ret = flb_processor_init(proc);
if (ret == -1) {
return -1;
}

return 0;
}

Expand Down