Skip to content

Commit bf5b38e

Browse files
fujimotosedsiper
authored andcommitted
in_tail: enable "real_name" support on the inotify backend
When in_tail watches a symbolic link, it occationally checks the target file (as well as the symlink itself) to see if the log file is rotated or not. Previously the inotify backend cannot handle this well, since it lacks the support for real_name in flb_tail_file struct. Evidently this has been causing failures with in_tail/run_tests.sh. This commit fixes it by adding that missing support. Signed-off-by: Fujimoto Seiji <[email protected]>
1 parent 230f294 commit bf5b38e

File tree

3 files changed

+1
-11
lines changed

3 files changed

+1
-11
lines changed

plugins/in_tail/tail_file.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -764,9 +764,7 @@ void flb_tail_file_remove(struct flb_tail_file *file)
764764

765765
flb_free(file->buf_data);
766766
flb_free(file->name);
767-
#if !defined(__linux__) || !defined(FLB_HAVE_INOTIFY)
768767
flb_free(file->real_name);
769-
#endif
770768

771769
#ifdef FLB_HAVE_METRICS
772770
flb_metrics_sum(FLB_TAIL_METRIC_F_CLOSED, 1, ctx->ins->metrics);
@@ -1134,7 +1132,6 @@ int flb_tail_file_name_dup(char *path, struct flb_tail_file *file)
11341132
}
11351133
file->name_len = strlen(file->name);
11361134

1137-
#if !defined(__linux__) || !defined(FLB_HAVE_INOTIFY)
11381135
if (file->real_name) {
11391136
flb_free(file->real_name);
11401137
}
@@ -1145,7 +1142,6 @@ int flb_tail_file_name_dup(char *path, struct flb_tail_file *file)
11451142
file->name = NULL;
11461143
return -1;
11471144
}
1148-
#endif
11491145

11501146
return 0;
11511147
}

plugins/in_tail/tail_file.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,7 @@ static inline int flb_tail_target_file_name_cmp(char *name,
8484
name_a = flb_strdup(name);
8585
base_a = flb_strdup(basename(name_a));
8686

87-
#if defined(__linux__) && defined(FLB_HAVE_INOTIFY)
88-
name_b = flb_strdup(file->name);
89-
base_b = basename(name_b);
90-
ret = strcmp(base_a, base_b);
91-
#elif defined(FLB_SYSTEM_WINDOWS)
87+
#if defined(FLB_SYSTEM_WINDOWS)
9288
name_b = flb_strdup(file->real_name);
9389
base_b = basename(name_b);
9490
ret = _stricmp(base_a, base_b);

plugins/in_tail/tail_file_internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ struct flb_tail_file {
4141
uint64_t link_inode;
4242
int is_link;
4343
char *name; /* target file name given by scan routine */
44-
#if !defined(__linux) || !defined(FLB_HAVE_INOTIFY)
4544
char *real_name; /* real file name in the file system */
46-
#endif
4745
size_t name_len;
4846
time_t rotated;
4947
off_t pending_bytes;

0 commit comments

Comments
 (0)