Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions plugins/in_tail/tail_fs_inotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
71 changes: 71 additions & 0 deletions tests/runtime/in_tail.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading