Skip to content
Open
Changes from all 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
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 <exlin@google.com>
  • Loading branch information
linxiulei committed Jan 4, 2025
commit 961e908c973c250e08537267502735b9ad3a5e16
12 changes: 11 additions & 1 deletion plugins/in_tail/tail_fs_stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ 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;

pending_data_detected = FLB_FALSE;

/* Lookup watched file */
mk_list_foreach_safe(head, tmp, &ctx->files_event) {
Expand Down Expand Up @@ -123,6 +126,9 @@ static int tail_fs_check(struct flb_input_instance *ins,
if (file->offset > st.st_size) {
offset = lseek(file->fd, 0, SEEK_SET);
if (offset == -1) {
if (pending_data_detected) {
tail_signal_pending(ctx);
}
flb_errno();
return -1;
}
Expand All @@ -142,7 +148,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;
Expand Down Expand Up @@ -173,6 +179,10 @@ static int tail_fs_check(struct flb_input_instance *ins,

}

if (pending_data_detected) {
tail_signal_pending(ctx);
}

return 0;
}

Expand Down