From fe588f54eb0cba2642126ecb1cca71beb3e68702 Mon Sep 17 00:00:00 2001 From: Michal Bloch Date: Tue, 9 Jun 2020 17:51:16 +0200 Subject: [PATCH] Fix infinite sleeps in low-log environments Change-Id: I3c3688d5bc05d648dfe2a38f349d2b403108a28a Signed-off-by: Michal Bloch --- src/libdlogutil/logretrieve.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libdlogutil/logretrieve.c b/src/libdlogutil/logretrieve.c index 892dbd0..890355f 100644 --- a/src/libdlogutil/logretrieve.c +++ b/src/libdlogutil/logretrieve.c @@ -385,13 +385,18 @@ int do_print_once(dlogutil_state_s *state, int timeout, dlogutil_entry_s **out) bool all_buffers_empty = false; int r = put_logs_into_vector(state->data_fds, state->fd_count, &state->logs, state->filter_object, &state->need_epoll, &all_buffers_empty, out); + + /* Putting logs into the vector can cause extra reads, + * which means a buffer might have gotten drained here + * and not at the regular refill stage. */ + remove_drained_buffers(state); + if (r < 0) return r; if (*out) return 0; set_flush_target(state, all_buffers_empty, last_log_age); - remove_drained_buffers(state); } int r; -- 2.7.4