diff --git a/base/src/event_demultiplexer.cpp b/base/src/event_demultiplexer.cpp index 765b7431327a1c1055f3da29e631744de50c0b7d..9e1633b320364e2b4b05ec737bc7f56819d3708b 100644 --- a/base/src/event_demultiplexer.cpp +++ b/base/src/event_demultiplexer.cpp @@ -111,7 +111,7 @@ void EventDemultiplexer::Polling(int timeout /* ms */) return; } if (nfds == -1) { - UTILS_LOGE("epoll_wait failed."); + UTILS_LOGE("epoll_wait failed, errno %{public}d", errno); return; } diff --git a/base/src/refbase.cpp b/base/src/refbase.cpp index ec969970ca386e65ec050c9b9aaad4ef1d86ee79..affddd942903cd1020d948dca3b24427740820c1 100644 --- a/base/src/refbase.cpp +++ b/base/src/refbase.cpp @@ -21,6 +21,19 @@ namespace OHOS { +void DebugRefBase() +{ +#ifdef DEBUG_REFBASE + if (enableTrack) { +#ifdef PRINT_TRACK_AT_ONCE + PrintRefs(objectId); +#else + GetNewTrace(objectId); +#endif + } +#endif +} + WeakRefCounter::WeakRefCounter(RefCounter *counter, void *cookie) : atomicWeak_(0), refCounter_(counter), cookie_(cookie) { @@ -213,15 +226,7 @@ RefCounter::~RefCounter() int RefCounter::IncStrongRefCount(const void* objectId) { -#ifdef DEBUG_REFBASE - if (enableTrack) { -#ifdef PRINT_TRACK_AT_ONCE - PrintRefs(objectId); -#else - GetNewTrace(objectId); -#endif - } -#endif + DebugRefBase(); int curCount = atomicStrong_.load(std::memory_order_relaxed); if (curCount >= 0) { curCount = atomicStrong_.fetch_add(1, std::memory_order_relaxed); @@ -235,15 +240,7 @@ int RefCounter::IncStrongRefCount(const void* objectId) int RefCounter::DecStrongRefCount(const void* objectId) { -#ifdef DEBUG_REFBASE - if (enableTrack) { -#ifdef PRINT_TRACK_AT_ONCE - PrintRefs(objectId); -#else - GetNewTrace(objectId); -#endif - } -#endif + DebugRefBase(); int curCount = GetStrongRefCount(); if (curCount == INITIAL_PRIMARY_VALUE) { // unexpected case: there had never a strong reference. @@ -264,29 +261,13 @@ int RefCounter::GetStrongRefCount() int RefCounter::IncWeakRefCount(const void* objectId) { -#ifdef DEBUG_REFBASE - if (enableTrack) { -#ifdef PRINT_TRACK_AT_ONCE - PrintRefs(objectId); -#else - GetNewTrace(objectId); -#endif - } -#endif + DebugRefBase(); return atomicWeak_.fetch_add(1, std::memory_order_relaxed); } int RefCounter::DecWeakRefCount(const void* objectId) { -#ifdef DEBUG_REFBASE - if (enableTrack) { -#ifdef PRINT_TRACK_AT_ONCE - PrintRefs(objectId); -#else - GetNewTrace(objectId); -#endif - } -#endif + DebugRefBase(); int curCount = GetWeakRefCount(); if (curCount > 0) { curCount = atomicWeak_.fetch_sub(1, std::memory_order_release);