From 699cab11807c5968e539b0eb7bfaaa08fd8522bc Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Mon, 29 Jun 2026 14:46:39 +0900 Subject: [PATCH 1/2] in_tail: Handle to pause inotify events on threaded mode Signed-off-by: Hiroshi Hatake --- plugins/in_tail/tail_fs_inotify.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/in_tail/tail_fs_inotify.c b/plugins/in_tail/tail_fs_inotify.c index c115ca5c014..5fdb231a49b 100644 --- a/plugins/in_tail/tail_fs_inotify.c +++ b/plugins/in_tail/tail_fs_inotify.c @@ -387,6 +387,10 @@ static int in_tail_progress_check_callback(struct flb_input_instance *ins, pending_data_detected = FLB_FALSE; + if (flb_input_buf_paused(ctx->ins) == FLB_TRUE) { + return 0; + } + mk_list_foreach_safe(head, tmp, &ctx->files_event) { file = mk_list_entry(head, struct flb_tail_file, _head); ret = reconcile_file_state(ctx, file, "in_tail_progress_check", &pending); From f816644c807c52f4ed3d67a281c4458b556cf29c Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Mon, 29 Jun 2026 14:47:07 +0900 Subject: [PATCH 2/2] tests: runtime: Add a test case for inotify with threaded mode Signed-off-by: Hiroshi Hatake --- tests/runtime/in_tail.c | 71 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/tests/runtime/in_tail.c b/tests/runtime/in_tail.c index 33d1ee6c669..8944d59b13b 100644 --- a/tests/runtime/in_tail.c +++ b/tests/runtime/in_tail.c @@ -2289,6 +2289,28 @@ void flb_test_inotify_watcher_false() } #ifdef FLB_HAVE_INOTIFY +static int wait_tail_collectors_state(struct flb_tail_config *tail_ctx, + struct flb_input_instance *ins, + int expected) +{ + int i; + int fs_running; + int progress_running; + + for (i = 0; i < 50; i++) { + fs_running = flb_input_collector_running(tail_ctx->coll_fd_fs1, ins); + progress_running = flb_input_collector_running(tail_ctx->coll_fd_progress_check, + ins); + if (fs_running == expected && progress_running == expected) { + return 0; + } + + flb_time_msleep(100); + } + + return -1; +} + void flb_test_inotify_pause_collectors() { int ret; @@ -2338,6 +2360,54 @@ void flb_test_inotify_pause_collectors() test_tail_ctx_destroy(ctx); } + +void flb_test_inotify_threaded_pause_collectors() +{ + int ret; + struct mk_list *head; + struct flb_input_instance *ins; + struct flb_tail_config *tail_ctx; + struct flb_lib_out_cb cb_data; + struct test_tail_ctx *ctx; + char *file[] = {"inotify_threaded_pause_collectors.log"}; + + cb_data.cb = cb_count_msgpack; + cb_data.data = NULL; + + ctx = test_tail_ctx_create(&cb_data, &file[0], 1, FLB_TRUE); + if (!TEST_CHECK(ctx != NULL)) { + TEST_MSG("test_ctx_create failed"); + exit(EXIT_FAILURE); + } + + ret = flb_input_set(ctx->flb, ctx->i_ffd, + "path", file[0], + "threaded", "true", + NULL); + TEST_CHECK(ret == 0); + + ret = flb_start(ctx->flb); + TEST_CHECK(ret == 0); + + head = ctx->flb->config->inputs.next; + ins = mk_list_entry(head, struct flb_input_instance, _head); + tail_ctx = ins->context; + + ret = wait_tail_collectors_state(tail_ctx, ins, FLB_TRUE); + TEST_CHECK(ret == 0); + + ret = flb_input_pause(ins); + TEST_CHECK(ret == 0); + ret = wait_tail_collectors_state(tail_ctx, ins, FLB_FALSE); + TEST_CHECK(ret == 0); + + ret = flb_input_resume(ins); + TEST_CHECK(ret == 0); + ret = wait_tail_collectors_state(tail_ctx, ins, FLB_TRUE); + TEST_CHECK(ret == 0); + + test_tail_ctx_destroy(ctx); +} #endif #ifdef FLB_HAVE_REGEX @@ -2942,6 +3012,7 @@ TEST_LIST = { #ifdef FLB_HAVE_INOTIFY {"inotify_watcher_false", flb_test_inotify_watcher_false}, {"inotify_pause_collectors", flb_test_inotify_pause_collectors}, + {"inotify_threaded_pause_collectors", flb_test_inotify_threaded_pause_collectors}, #endif /* FLB_HAVE_INOTIFY */ #ifdef FLB_HAVE_REGEX