Skip to content

Commit

Permalink
filter_rewrite_tag: set 'keep' before emitting(#4518)
Browse files Browse the repository at this point in the history
'keep' is set when process_record returns FLB_TRUE.
It indicates some records can be dropped.

e.g. If first record is not matched regex, 'keep' is not initialized.
'keep' is undefined and it can be different from FLB_TRUE.
It causes the first record is lost even if user sets 'KEEP' is true.

Signed-off-by: Takahiro Yamashita <[email protected]>
  • Loading branch information
nokute78 authored and edsiper committed Jan 23, 2022
1 parent 27b37fd commit b6668b1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion plugins/filter_rewrite_tag/rewrite_tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ static int process_record(const char *tag, int tag_len, msgpack_object map,

mk_list_foreach(head, &ctx->rules) {
rule = mk_list_entry(head, struct rewrite_rule, _head);
if (rule) {
*keep = rule->keep_record;
}
ret = flb_ra_regex_match(rule->ra_key, map, rule->regex, &result);
if (ret < 0) { /* no match */
rule = NULL;
Expand Down Expand Up @@ -359,7 +362,7 @@ static int process_record(const char *tag, int tag_len, msgpack_object map,
return FLB_FALSE;
}

*keep = rule->keep_record;

return FLB_TRUE;
}

Expand Down

0 comments on commit b6668b1

Please sign in to comment.