diff --git a/base/src/event_demultiplexer.cpp b/base/src/event_demultiplexer.cpp index d35b8115b3ab9ee9cb2e86a0fcba1791a413180e..ec656f115cfe54778ada55344b7a4e338d16ae44 100644 --- a/base/src/event_demultiplexer.cpp +++ b/base/src/event_demultiplexer.cpp @@ -33,7 +33,8 @@ static const int EPOLL_ERROR_BADF = 9; static const int EPOLL_ERROR_EINVAL = 22; EventDemultiplexer::EventDemultiplexer() - : epollFd_(epoll_create1(EPOLL_CLOEXEC)), maxEvents_(EPOLL_MAX_EVENS_INIT), mutex_(), eventHandlers_() + : epollFd_(epoll_create1(EPOLL_CLOEXEC)), maxEvents_(EPOLL_MAX_EVENS_INIT), mutex_(), eventHandlers_(), + epollCtlErrInfo_(0, 0, 0) { } @@ -93,8 +94,9 @@ uint32_t EventDemultiplexer::Update(int operation, EventHandler* handler) event.data.fd = handler->GetHandle(); if (epoll_ctl(epollFd_, operation, handler->GetHandle(), &event) != 0) { - UTILS_LOGD("epoll_ctl %{public}d operation %{public}d on handle %{public}d failed", + UTILS_LOGE("epoll_ctl %{public}d operation %{public}d on handle %{public}d failed", epollFd_, operation, handler->GetHandle()); + epollCtlErrInfo_ = std::make_tuple(operation, errno, handler->GetHandle()); return TIMER_ERR_DEAL_FAILED; } return TIMER_ERR_OK; @@ -133,7 +135,9 @@ int EventDemultiplexer::Polling(int timeout /* ms */) taskQue.emplace_back(itor->second); eventQue.emplace_back(events); } else { - UTILS_LOGE("fd not found in eventHandlers_, fd=%{public}d, events=%{public}d", targetFd, events); + auto [operation, errnoNum, fd] = epollCtlErrInfo_; + UTILS_LOGE("fd not found, fd: %{public}d, events: %{public}d, epoll_ctl: %{public}d, %{public}d," + "%{public}d", targetFd, events, operation, errnoNum, fd); } } } diff --git a/base/src/event_demultiplexer.h b/base/src/event_demultiplexer.h index 75a3d7b0fa56bcc0fabe8914d317e892bfa389be..bc54d1347ea5e6742600280bb366ea57af3d8cb6 100644 --- a/base/src/event_demultiplexer.h +++ b/base/src/event_demultiplexer.h @@ -20,6 +20,7 @@ #include #include #include +#include namespace OHOS { namespace Utils { @@ -49,6 +50,7 @@ private: int maxEvents_; std::recursive_mutex mutex_; std::map> eventHandlers_; // guard by mutex_ + std::tuple epollCtlErrInfo_; }; }