From: Michal Bloch Date: Fri, 27 Mar 2020 19:29:54 +0000 (+0100) Subject: libdlogutil: support timeout param (nominally) X-Git-Tag: submit/tizen/20200406.080750~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d9a753742d774ce801aba1e29b61b2164938e14b;p=platform%2Fcore%2Fsystem%2Fdlog.git libdlogutil: support timeout param (nominally) Change-Id: I405093fb559b4f1935e404aa8ae3f597fcdf6cb0 Signed-off-by: Michal Bloch --- diff --git a/src/libdlogutil/logretrieve.c b/src/libdlogutil/logretrieve.c index eb5d4ec..2646a3d 100644 --- a/src/libdlogutil/logretrieve.c +++ b/src/libdlogutil/logretrieve.c @@ -22,6 +22,12 @@ // C #include + +/* This is the timeout used by the "old" API currently being torn down. + * It cannot be -1 because then logs won't be flushed. It has to be + * some reasonably low value to keep dlogutil responsive. */ +#define DEFAULT_EPOLL_TIMEOUT 100 + int create_initial_fdis(struct fd_info ***fdis, int enabled_buffers, bool is_pipe, const struct log_config *conf) { assert(fdis); @@ -233,7 +239,7 @@ int dlogutil_state_init(dlogutil_state_s *state, struct fd_info ***data_fds_ptr, * @param[in] l_file File output metadata * @return int 0 if successful, a negative value on error, callback's return value if it isn't 0 */ -int do_print_once(dlogutil_state_s *state, dlogutil_entry_s **out) +int do_print_once(dlogutil_state_s *state, int timeout, dlogutil_entry_s **out) { *out = NULL; while (state->epoll_cnt > 0) { @@ -258,7 +264,7 @@ int do_print_once(dlogutil_state_s *state, dlogutil_entry_s **out) if (r == BUFFER_NEWLY_DRAINED || r == ALL_BUFFERS_EMPTY) { - int const nfds = TEMP_FAILURE_RETRY(epoll_wait(state->epollfd, state->evs, state->epoll_cnt, 100)); + int const nfds = epoll_wait(state->epollfd, state->evs, state->epoll_cnt, timeout); if (nfds < 0) return -errno; @@ -346,7 +352,10 @@ int do_print(dlogutil_state_s *state, dlogutil_entry_cb callback, void *userdata { while (true) { dlogutil_entry_s *out; - int r = do_print_once(state, &out); + int r; + do + r = do_print_once(state, DEFAULT_EPOLL_TIMEOUT, &out); + while (r == -EINTR); if (r != 0) return r;