libdlogutil: make the epoll check stateful 22/231022/1
authorMichal Bloch <m.bloch@samsung.com>
Thu, 16 Apr 2020 16:38:29 +0000 (18:38 +0200)
committerMichal Bloch <m.bloch@samsung.com>
Thu, 16 Apr 2020 18:25:39 +0000 (20:25 +0200)
Change-Id: I4ae42ed3a94f644e7e63f55c79c17c62edd0f52b
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
src/libdlogutil/logretrieve.c

index 379cb2c..59b147d 100644 (file)
@@ -362,26 +362,23 @@ int do_print_once(dlogutil_state_s *state, int timeout, dlogutil_entry_s **out)
        assert(!*out);
 
        while (state->epoll_cnt > 0) {
+               if (state->need_epoll) {
+                       int r = refill_fdi_buffers(state, timeout);
+                       if (r < 0)
+                               return r;
+                       state->need_epoll = false;
+               }
+
                if (handle_flush(state, out))
                        return 0;
 
                bool all_buffers_empty = false;
-               state->need_epoll = 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);
                if (r < 0)
                        return r;
-
-               int refill_err = 0;
-               if (state->need_epoll)
-                       refill_err = refill_fdi_buffers(state, timeout);
-
                if (*out)
                        return 0;
 
-               // Don't do that immediately to prevent 'out' leaking
-               if (refill_err)
-                       return refill_err;
-
                set_flush_target(state, all_buffers_empty);
                remove_drained_buffers(state);
        }