From bf02bef02e2184ffc03dae38a17a007c7758ec8f Mon Sep 17 00:00:00 2001 From: wujianlin Date: Thu, 22 May 2025 11:43:52 +0800 Subject: [PATCH] Add TimeOut exception dimension measurement information Issue:https://gitee.com/openharmony/commonlibrary_c_utils/issues/IC9N19?from=project-issue Signed-off-by: wujianlin --- base/src/timer_event_handler.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/base/src/timer_event_handler.cpp b/base/src/timer_event_handler.cpp index 75e7d41..0dd9952 100644 --- a/base/src/timer_event_handler.cpp +++ b/base/src/timer_event_handler.cpp @@ -98,8 +98,17 @@ void TimerEventHandler::TimeOut() uint64_t expirations = 0; ssize_t n = ::read(GetHandle(), &expirations, sizeof(expirations)); if (n != sizeof(expirations)) { - UTILS_LOGE("epoll_loop::on_timer() reads %{public}d bytes instead of 8, errno=%{public}d", static_cast(n), - errno); + int erronRead = errno; + struct itimerspec current = { + .it_interval = {.tv_sec = -1, .tv_nsec = -1}, + .it_value = {.tv_sec = -1, .tv_nsec = -1} + }; + if (timerfd_gettime(GetHandle(), ¤t) == -1) { + UTILS_LOGE("timerfd_gettime failed, errno=%{public}d", errno); + } + UTILS_LOGE("epoll_loop::on_timer() reads %{public}d bytes instead of 8, timerFd=%{public}d, errno=%{public}d, " + "Current timer value: %{public}lld sec, %{public}ld nsec", static_cast(n), GetHandle(), + erronRead, static_cast(current.it_value.tv_sec), current.it_value.tv_nsec); } if (callback_) { callback_(GetHandle()); -- Gitee