Loading logd/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -36,9 +36,9 @@ cc_library_static { "CommandListener.cpp", "LogListener.cpp", "LogReader.cpp", "LogReaderThread.cpp", "LogBuffer.cpp", "LogBufferElement.cpp", "LogTimes.cpp", "LogStatistics.cpp", "LogWhiteBlackList.cpp", "libaudit.c", Loading logd/LogAudit.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -277,7 +277,7 @@ int LogAudit::logPrint(const char* fmt, ...) { : LOGGER_ENTRY_MAX_PAYLOAD; size_t message_len = str_len + sizeof(android_log_event_string_t); log_mask_t notify = 0; unsigned int notify = 0; if (events) { // begin scope for event buffer uint32_t buffer[(message_len + sizeof(uint32_t) - 1) / sizeof(uint32_t)]; Loading logd/LogBuffer.cpp +26 −27 Original line number Diff line number Diff line Loading @@ -93,16 +93,16 @@ void LogBuffer::init() { } // Release any sleeping reader threads to dump their current content. LogTimeEntry::wrlock(); LogReaderThread::wrlock(); LastLogTimes::iterator times = mTimes.begin(); while (times != mTimes.end()) { LogTimeEntry* entry = times->get(); LogReaderThread* entry = times->get(); entry->triggerReader_Locked(); times++; } LogTimeEntry::unlock(); LogReaderThread::unlock(); } LogBuffer::LogBuffer(LastLogTimes* times, LogTags* tags, PruneList* prune) Loading Loading @@ -579,14 +579,14 @@ class LogBufferElementLast { // If the selected reader is blocking our pruning progress, decide on // what kind of mitigation is necessary to unblock the situation. void LogBuffer::kickMe(LogTimeEntry* me, log_id_t id, unsigned long pruneRows) { void LogBuffer::kickMe(LogReaderThread* me, log_id_t id, unsigned long pruneRows) { if (stats.sizes(id) > (2 * log_buffer_size(id))) { // +100% // A misbehaving or slow reader has its connection // dropped if we hit too much memory pressure. android::prdebug("Kicking blocked reader, pid %d, from LogBuffer::kickMe()\n", me->mClient->getPid()); me->client()->getPid()); me->release_Locked(); } else if (me->mTimeout.tv_sec || me->mTimeout.tv_nsec) { } else if (me->timeout().tv_sec || me->timeout().tv_nsec) { // Allow a blocked WRAP timeout reader to // trigger and start reporting the log data. me->triggerReader_Locked(); Loading @@ -594,7 +594,7 @@ void LogBuffer::kickMe(LogTimeEntry* me, log_id_t id, unsigned long pruneRows) { // tell slow reader to skip entries to catch up android::prdebug( "Skipping %lu entries from slow reader, pid %d, from LogBuffer::kickMe()\n", pruneRows, me->mClient->getPid()); pruneRows, me->client()->getPid()); me->triggerSkip_Locked(id, pruneRows); } } Loading Loading @@ -647,20 +647,19 @@ void LogBuffer::kickMe(LogTimeEntry* me, log_id_t id, unsigned long pruneRows) { // LogBuffer::wrlock() must be held when this function is called. // bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { LogTimeEntry* oldest = nullptr; LogReaderThread* oldest = nullptr; bool busy = false; bool clearAll = pruneRows == ULONG_MAX; LogTimeEntry::rdlock(); LogReaderThread::rdlock(); // Region locked? LastLogTimes::iterator times = mTimes.begin(); while (times != mTimes.end()) { LogTimeEntry* entry = times->get(); if (entry->isWatching(id) && (!oldest || (oldest->mStart > entry->mStart) || ((oldest->mStart == entry->mStart) && (entry->mTimeout.tv_sec || entry->mTimeout.tv_nsec)))) { LogReaderThread* entry = times->get(); if (entry->IsWatching(id) && (!oldest || oldest->start() > entry->start() || (oldest->start() == entry->start() && (entry->timeout().tv_sec || entry->timeout().tv_nsec)))) { oldest = entry; } times++; Loading @@ -681,7 +680,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { continue; } if (oldest && oldest->mStart <= element->getSequence()) { if (oldest && oldest->start() <= element->getSequence()) { busy = true; kickMe(oldest, id, pruneRows); break; Loading @@ -692,7 +691,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { break; } } LogTimeEntry::unlock(); LogReaderThread::unlock(); return busy; } Loading Loading @@ -772,7 +771,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { while (it != mLogElements.end()) { LogBufferElement* element = *it; if (oldest && oldest->mStart <= element->getSequence()) { if (oldest && oldest->start() <= element->getSequence()) { busy = true; // Do not let chatty eliding trigger any reader mitigation break; Loading Loading @@ -914,7 +913,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { continue; } if (oldest && oldest->mStart <= element->getSequence()) { if (oldest && oldest->start() <= element->getSequence()) { busy = true; if (!whitelist) kickMe(oldest, id, pruneRows); break; Loading Loading @@ -942,7 +941,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { continue; } if (oldest && oldest->mStart <= element->getSequence()) { if (oldest && oldest->start() <= element->getSequence()) { busy = true; kickMe(oldest, id, pruneRows); break; Loading @@ -953,7 +952,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { } } LogTimeEntry::unlock(); LogReaderThread::unlock(); return (pruneRows > 0) && busy; } Loading @@ -976,20 +975,20 @@ bool LogBuffer::clear(log_id_t id, uid_t uid) { // readers and let the clear run (below) deal with determining // if we are still blocked and return an error code to caller. if (busy) { LogTimeEntry::wrlock(); LogReaderThread::wrlock(); LastLogTimes::iterator times = mTimes.begin(); while (times != mTimes.end()) { LogTimeEntry* entry = times->get(); LogReaderThread* entry = times->get(); // Killer punch if (entry->isWatching(id)) { if (entry->IsWatching(id)) { android::prdebug( "Kicking blocked reader, pid %d, from LogBuffer::clear()\n", entry->mClient->getPid()); entry->client()->getPid()); entry->release_Locked(); } times++; } LogTimeEntry::unlock(); LogReaderThread::unlock(); } } wrlock(); Loading Loading @@ -1033,7 +1032,7 @@ unsigned long LogBuffer::getSize(log_id_t id) { uint64_t LogBuffer::flushTo(SocketClient* reader, uint64_t start, pid_t* lastTid, bool privileged, bool security, int (*filter)(const LogBufferElement* element, void* arg), void* arg) { const std::function<int(const LogBufferElement* element)>& filter) { LogBufferElementCollection::iterator it; uid_t uid = reader->getUid(); Loading Loading @@ -1071,7 +1070,7 @@ uint64_t LogBuffer::flushTo(SocketClient* reader, uint64_t start, pid_t* lastTid // NB: calling out to another object with wrlock() held (safe) if (filter) { int ret = (*filter)(element, arg); int ret = filter(element); if (ret == false) { continue; } Loading logd/LogBuffer.h +3 −4 Original line number Diff line number Diff line Loading @@ -27,9 +27,9 @@ #include <sysutils/SocketClient.h> #include "LogBufferElement.h" #include "LogReaderThread.h" #include "LogStatistics.h" #include "LogTags.h" #include "LogTimes.h" #include "LogWhiteBlackList.h" // Loading Loading @@ -115,8 +115,7 @@ class LogBuffer { uint64_t flushTo(SocketClient* writer, uint64_t start, pid_t* lastTid, // &lastTid[LOG_ID_MAX] or nullptr bool privileged, bool security, int (*filter)(const LogBufferElement* element, void* arg) = nullptr, void* arg = nullptr); const std::function<int(const LogBufferElement* element)>& filter); bool clear(log_id_t id, uid_t uid = AID_ROOT); unsigned long getSize(log_id_t id); Loading Loading @@ -152,7 +151,7 @@ class LogBuffer { static constexpr size_t maxPrune = 256; void maybePrune(log_id_t id); void kickMe(LogTimeEntry* me, log_id_t id, unsigned long pruneRows); void kickMe(LogReaderThread* me, log_id_t id, unsigned long pruneRows); bool prune(log_id_t id, unsigned long pruneRows, uid_t uid = AID_ROOT); LogBufferElementCollection::iterator erase( Loading logd/LogKlog.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -819,7 +819,7 @@ int LogKlog::log(const char* buf, ssize_t len) { // notify readers if (rc > 0) { reader->notifyNewLog(static_cast<log_mask_t>(1 << LOG_ID_KERNEL)); reader->notifyNewLog(static_cast<unsigned int>(1 << LOG_ID_KERNEL)); } return rc; Loading Loading
logd/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -36,9 +36,9 @@ cc_library_static { "CommandListener.cpp", "LogListener.cpp", "LogReader.cpp", "LogReaderThread.cpp", "LogBuffer.cpp", "LogBufferElement.cpp", "LogTimes.cpp", "LogStatistics.cpp", "LogWhiteBlackList.cpp", "libaudit.c", Loading
logd/LogAudit.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -277,7 +277,7 @@ int LogAudit::logPrint(const char* fmt, ...) { : LOGGER_ENTRY_MAX_PAYLOAD; size_t message_len = str_len + sizeof(android_log_event_string_t); log_mask_t notify = 0; unsigned int notify = 0; if (events) { // begin scope for event buffer uint32_t buffer[(message_len + sizeof(uint32_t) - 1) / sizeof(uint32_t)]; Loading
logd/LogBuffer.cpp +26 −27 Original line number Diff line number Diff line Loading @@ -93,16 +93,16 @@ void LogBuffer::init() { } // Release any sleeping reader threads to dump their current content. LogTimeEntry::wrlock(); LogReaderThread::wrlock(); LastLogTimes::iterator times = mTimes.begin(); while (times != mTimes.end()) { LogTimeEntry* entry = times->get(); LogReaderThread* entry = times->get(); entry->triggerReader_Locked(); times++; } LogTimeEntry::unlock(); LogReaderThread::unlock(); } LogBuffer::LogBuffer(LastLogTimes* times, LogTags* tags, PruneList* prune) Loading Loading @@ -579,14 +579,14 @@ class LogBufferElementLast { // If the selected reader is blocking our pruning progress, decide on // what kind of mitigation is necessary to unblock the situation. void LogBuffer::kickMe(LogTimeEntry* me, log_id_t id, unsigned long pruneRows) { void LogBuffer::kickMe(LogReaderThread* me, log_id_t id, unsigned long pruneRows) { if (stats.sizes(id) > (2 * log_buffer_size(id))) { // +100% // A misbehaving or slow reader has its connection // dropped if we hit too much memory pressure. android::prdebug("Kicking blocked reader, pid %d, from LogBuffer::kickMe()\n", me->mClient->getPid()); me->client()->getPid()); me->release_Locked(); } else if (me->mTimeout.tv_sec || me->mTimeout.tv_nsec) { } else if (me->timeout().tv_sec || me->timeout().tv_nsec) { // Allow a blocked WRAP timeout reader to // trigger and start reporting the log data. me->triggerReader_Locked(); Loading @@ -594,7 +594,7 @@ void LogBuffer::kickMe(LogTimeEntry* me, log_id_t id, unsigned long pruneRows) { // tell slow reader to skip entries to catch up android::prdebug( "Skipping %lu entries from slow reader, pid %d, from LogBuffer::kickMe()\n", pruneRows, me->mClient->getPid()); pruneRows, me->client()->getPid()); me->triggerSkip_Locked(id, pruneRows); } } Loading Loading @@ -647,20 +647,19 @@ void LogBuffer::kickMe(LogTimeEntry* me, log_id_t id, unsigned long pruneRows) { // LogBuffer::wrlock() must be held when this function is called. // bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { LogTimeEntry* oldest = nullptr; LogReaderThread* oldest = nullptr; bool busy = false; bool clearAll = pruneRows == ULONG_MAX; LogTimeEntry::rdlock(); LogReaderThread::rdlock(); // Region locked? LastLogTimes::iterator times = mTimes.begin(); while (times != mTimes.end()) { LogTimeEntry* entry = times->get(); if (entry->isWatching(id) && (!oldest || (oldest->mStart > entry->mStart) || ((oldest->mStart == entry->mStart) && (entry->mTimeout.tv_sec || entry->mTimeout.tv_nsec)))) { LogReaderThread* entry = times->get(); if (entry->IsWatching(id) && (!oldest || oldest->start() > entry->start() || (oldest->start() == entry->start() && (entry->timeout().tv_sec || entry->timeout().tv_nsec)))) { oldest = entry; } times++; Loading @@ -681,7 +680,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { continue; } if (oldest && oldest->mStart <= element->getSequence()) { if (oldest && oldest->start() <= element->getSequence()) { busy = true; kickMe(oldest, id, pruneRows); break; Loading @@ -692,7 +691,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { break; } } LogTimeEntry::unlock(); LogReaderThread::unlock(); return busy; } Loading Loading @@ -772,7 +771,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { while (it != mLogElements.end()) { LogBufferElement* element = *it; if (oldest && oldest->mStart <= element->getSequence()) { if (oldest && oldest->start() <= element->getSequence()) { busy = true; // Do not let chatty eliding trigger any reader mitigation break; Loading Loading @@ -914,7 +913,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { continue; } if (oldest && oldest->mStart <= element->getSequence()) { if (oldest && oldest->start() <= element->getSequence()) { busy = true; if (!whitelist) kickMe(oldest, id, pruneRows); break; Loading Loading @@ -942,7 +941,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { continue; } if (oldest && oldest->mStart <= element->getSequence()) { if (oldest && oldest->start() <= element->getSequence()) { busy = true; kickMe(oldest, id, pruneRows); break; Loading @@ -953,7 +952,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { } } LogTimeEntry::unlock(); LogReaderThread::unlock(); return (pruneRows > 0) && busy; } Loading @@ -976,20 +975,20 @@ bool LogBuffer::clear(log_id_t id, uid_t uid) { // readers and let the clear run (below) deal with determining // if we are still blocked and return an error code to caller. if (busy) { LogTimeEntry::wrlock(); LogReaderThread::wrlock(); LastLogTimes::iterator times = mTimes.begin(); while (times != mTimes.end()) { LogTimeEntry* entry = times->get(); LogReaderThread* entry = times->get(); // Killer punch if (entry->isWatching(id)) { if (entry->IsWatching(id)) { android::prdebug( "Kicking blocked reader, pid %d, from LogBuffer::clear()\n", entry->mClient->getPid()); entry->client()->getPid()); entry->release_Locked(); } times++; } LogTimeEntry::unlock(); LogReaderThread::unlock(); } } wrlock(); Loading Loading @@ -1033,7 +1032,7 @@ unsigned long LogBuffer::getSize(log_id_t id) { uint64_t LogBuffer::flushTo(SocketClient* reader, uint64_t start, pid_t* lastTid, bool privileged, bool security, int (*filter)(const LogBufferElement* element, void* arg), void* arg) { const std::function<int(const LogBufferElement* element)>& filter) { LogBufferElementCollection::iterator it; uid_t uid = reader->getUid(); Loading Loading @@ -1071,7 +1070,7 @@ uint64_t LogBuffer::flushTo(SocketClient* reader, uint64_t start, pid_t* lastTid // NB: calling out to another object with wrlock() held (safe) if (filter) { int ret = (*filter)(element, arg); int ret = filter(element); if (ret == false) { continue; } Loading
logd/LogBuffer.h +3 −4 Original line number Diff line number Diff line Loading @@ -27,9 +27,9 @@ #include <sysutils/SocketClient.h> #include "LogBufferElement.h" #include "LogReaderThread.h" #include "LogStatistics.h" #include "LogTags.h" #include "LogTimes.h" #include "LogWhiteBlackList.h" // Loading Loading @@ -115,8 +115,7 @@ class LogBuffer { uint64_t flushTo(SocketClient* writer, uint64_t start, pid_t* lastTid, // &lastTid[LOG_ID_MAX] or nullptr bool privileged, bool security, int (*filter)(const LogBufferElement* element, void* arg) = nullptr, void* arg = nullptr); const std::function<int(const LogBufferElement* element)>& filter); bool clear(log_id_t id, uid_t uid = AID_ROOT); unsigned long getSize(log_id_t id); Loading Loading @@ -152,7 +151,7 @@ class LogBuffer { static constexpr size_t maxPrune = 256; void maybePrune(log_id_t id); void kickMe(LogTimeEntry* me, log_id_t id, unsigned long pruneRows); void kickMe(LogReaderThread* me, log_id_t id, unsigned long pruneRows); bool prune(log_id_t id, unsigned long pruneRows, uid_t uid = AID_ROOT); LogBufferElementCollection::iterator erase( Loading
logd/LogKlog.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -819,7 +819,7 @@ int LogKlog::log(const char* buf, ssize_t len) { // notify readers if (rc > 0) { reader->notifyNewLog(static_cast<log_mask_t>(1 << LOG_ID_KERNEL)); reader->notifyNewLog(static_cast<unsigned int>(1 << LOG_ID_KERNEL)); } return rc; Loading