From 210178b62554e56eca787933e556621622e2c65e Mon Sep 17 00:00:00 2001 From: Eric Lin Date: Sat, 6 Jul 2024 09:08:19 +0000 Subject: [PATCH] in_tail: signal pending only once Prior to this commit, if the tail is watching over multiple files, each file signals pending and results in calling in_tail_collect_pending() multiple times. Since function in_tail_collect_pending() goes through all watched files for pending data so calling it once is sufficient. This commit changes that by only signal pending event when there is any pending data from any watched files. Signed-off-by: Eric Lin --- plugins/in_tail/tail_fs_stat.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/in_tail/tail_fs_stat.c b/plugins/in_tail/tail_fs_stat.c index 1141af6856a..b615b5fbd5f 100644 --- a/plugins/in_tail/tail_fs_stat.c +++ b/plugins/in_tail/tail_fs_stat.c @@ -93,6 +93,7 @@ static int tail_fs_check(struct flb_input_instance *ins, struct flb_tail_file *file = NULL; struct fs_stat *fst; struct stat st; + int pending_data_detected; /* Lookup watched file */ mk_list_foreach_safe(head, tmp, &ctx->files_event) { @@ -142,7 +143,7 @@ static int tail_fs_check(struct flb_input_instance *ins, if (file->offset < st.st_size) { file->pending_bytes = (st.st_size - file->offset); - tail_signal_pending(ctx); + pending_data_detected = FLB_TRUE; } else { file->pending_bytes = 0; @@ -173,6 +174,10 @@ static int tail_fs_check(struct flb_input_instance *ins, } + if (pending_data_detected) { + tail_signal_pending(ctx); + } + return 0; }