Skip to content

Commit ee50311

Browse files
committed
in_tail: Process truncations only if the buffer limit is exceeded
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 31790d5 commit ee50311

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

plugins/in_tail/tail_file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,8 @@ static int process_content(struct flb_tail_file *file, size_t *bytes)
570570
data = (char *)flb_skip_leading_zeros_simd(data, end, &processed_bytes);
571571
}
572572

573-
if (ctx->truncate_long_lines == FLB_TRUE) {
573+
if (ctx->truncate_long_lines == FLB_TRUE &&
574+
file->buf_size >= ctx->buf_max_size) {
574575
/* Use buf_max_size as the truncation threshold */
575576
if (ctx->buf_max_size > 0) {
576577
eff_max = ctx->buf_max_size - 1;
@@ -585,8 +586,7 @@ static int process_content(struct flb_tail_file *file, size_t *bytes)
585586
}
586587

587588
nl = memchr(data, '\n', window);
588-
if (file->buf_size >= ctx->buf_max_size &&
589-
nl == NULL && eff_max > 0 && dec_len >= eff_max) {
589+
if (nl == NULL && eff_max > 0 && dec_len >= eff_max) {
590590
if (file->skip_next == FLB_TRUE) {
591591
bytes_override = (original_len > 0) ? original_len : file->buf_len;
592592
goto truncation_end;

0 commit comments

Comments
 (0)