Loading logd/LogBuffer.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -281,7 +281,8 @@ public: } void clear(LogBufferElement *e) { uint64_t current = e->getRealTime().nsec() - NS_PER_SEC; uint64_t current = e->getRealTime().nsec() - (EXPIRE_RATELIMIT * NS_PER_SEC); for(LogBufferElementMap::iterator it = map.begin(); it != map.end();) { LogBufferElement *l = it->second; if ((l->getDropped() >= EXPIRE_THRESHOLD) Loading logd/LogBufferElement.cpp +15 −9 Original line number Diff line number Diff line Loading @@ -104,8 +104,8 @@ char *android::tidToName(pid_t tid) { // assumption: mMsg == NULL size_t LogBufferElement::populateDroppedMessage(char *&buffer, LogBuffer *parent) { static const char tag[] = "logd"; static const char format_uid[] = "uid=%u%s too chatty%s, expire %u line%s"; static const char tag[] = "chatty"; static const char format_uid[] = "uid=%u%s%s expire %u line%s"; char *name = parent->uidToName(mUid); char *commName = android::tidToName(mTid); Loading @@ -115,9 +115,15 @@ size_t LogBufferElement::populateDroppedMessage(char *&buffer, if (!commName) { commName = parent->pidToName(mPid); } if (name && commName && !strcmp(name, commName)) { size_t len = name ? strlen(name) : 0; if (len && commName && !strncmp(name, commName, len)) { if (commName[len] == '\0') { free(commName); commName = NULL; } else { free(name); name = NULL; } } if (name) { char *p = NULL; Loading @@ -129,14 +135,14 @@ size_t LogBufferElement::populateDroppedMessage(char *&buffer, } if (commName) { char *p = NULL; asprintf(&p, " comm=%s", commName); asprintf(&p, " %s", commName); if (p) { free(commName); commName = p; } } // identical to below to calculate the buffer size required size_t len = snprintf(NULL, 0, format_uid, mUid, name ? name : "", len = snprintf(NULL, 0, format_uid, mUid, name ? name : "", commName ? commName : "", mDropped, (mDropped > 1) ? "s" : ""); Loading logd/LogBufferElement.h +2 −1 Original line number Diff line number Diff line Loading @@ -50,8 +50,9 @@ class LogBuffer; #define EXPIRE_HOUR_THRESHOLD 24 // Only expire chatty UID logs to preserve // non-chatty UIDs less than this age in hours #define EXPIRE_THRESHOLD 4 // A smaller expire count is considered too #define EXPIRE_THRESHOLD 10 // A smaller expire count is considered too // chatty for the temporal expire messages #define EXPIRE_RATELIMIT 10 // maximum rate in seconds to report expiration class LogBufferElement { const log_id_t mLogId; Loading logd/LogTimes.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ LogTimeEntry::LogTimeEntry(LogReader &reader, SocketClient *client, mRelease(false), mError(false), threadRunning(false), leadingDropped(false), mReader(reader), mLogMask(logMask), mPid(pid), Loading Loading @@ -123,6 +124,8 @@ void *LogTimeEntry::threadStart(void *obj) { bool privileged = FlushCommand::hasReadLogs(client); me->leadingDropped = true; lock(); while (me->threadRunning && !me->isError_Locked()) { Loading @@ -132,6 +135,7 @@ void *LogTimeEntry::threadStart(void *obj) { if (me->mTail) { logbuf.flushTo(client, start, privileged, FilterFirstPass, me); me->leadingDropped = true; } start = logbuf.flushTo(client, start, privileged, FilterSecondPass, me); Loading Loading @@ -163,6 +167,14 @@ int LogTimeEntry::FilterFirstPass(const LogBufferElement *element, void *obj) { LogTimeEntry::lock(); if (me->leadingDropped) { if (element->getDropped()) { LogTimeEntry::unlock(); return false; } me->leadingDropped = false; } if (me->mCount == 0) { me->mStart = element->getSequence(); } Loading Loading @@ -190,6 +202,13 @@ int LogTimeEntry::FilterSecondPass(const LogBufferElement *element, void *obj) { goto skip; } if (me->leadingDropped) { if (element->getDropped()) { goto skip; } me->leadingDropped = false; } // Truncate to close race between first and second pass if (me->mNonBlock && me->mTail && (me->mIndex >= me->mCount)) { goto stop; Loading logd/LogTimes.h +1 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ class LogTimeEntry { bool mRelease; bool mError; bool threadRunning; bool leadingDropped; pthread_cond_t threadTriggeredCondition; pthread_t mThread; LogReader &mReader; Loading Loading
logd/LogBuffer.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -281,7 +281,8 @@ public: } void clear(LogBufferElement *e) { uint64_t current = e->getRealTime().nsec() - NS_PER_SEC; uint64_t current = e->getRealTime().nsec() - (EXPIRE_RATELIMIT * NS_PER_SEC); for(LogBufferElementMap::iterator it = map.begin(); it != map.end();) { LogBufferElement *l = it->second; if ((l->getDropped() >= EXPIRE_THRESHOLD) Loading
logd/LogBufferElement.cpp +15 −9 Original line number Diff line number Diff line Loading @@ -104,8 +104,8 @@ char *android::tidToName(pid_t tid) { // assumption: mMsg == NULL size_t LogBufferElement::populateDroppedMessage(char *&buffer, LogBuffer *parent) { static const char tag[] = "logd"; static const char format_uid[] = "uid=%u%s too chatty%s, expire %u line%s"; static const char tag[] = "chatty"; static const char format_uid[] = "uid=%u%s%s expire %u line%s"; char *name = parent->uidToName(mUid); char *commName = android::tidToName(mTid); Loading @@ -115,9 +115,15 @@ size_t LogBufferElement::populateDroppedMessage(char *&buffer, if (!commName) { commName = parent->pidToName(mPid); } if (name && commName && !strcmp(name, commName)) { size_t len = name ? strlen(name) : 0; if (len && commName && !strncmp(name, commName, len)) { if (commName[len] == '\0') { free(commName); commName = NULL; } else { free(name); name = NULL; } } if (name) { char *p = NULL; Loading @@ -129,14 +135,14 @@ size_t LogBufferElement::populateDroppedMessage(char *&buffer, } if (commName) { char *p = NULL; asprintf(&p, " comm=%s", commName); asprintf(&p, " %s", commName); if (p) { free(commName); commName = p; } } // identical to below to calculate the buffer size required size_t len = snprintf(NULL, 0, format_uid, mUid, name ? name : "", len = snprintf(NULL, 0, format_uid, mUid, name ? name : "", commName ? commName : "", mDropped, (mDropped > 1) ? "s" : ""); Loading
logd/LogBufferElement.h +2 −1 Original line number Diff line number Diff line Loading @@ -50,8 +50,9 @@ class LogBuffer; #define EXPIRE_HOUR_THRESHOLD 24 // Only expire chatty UID logs to preserve // non-chatty UIDs less than this age in hours #define EXPIRE_THRESHOLD 4 // A smaller expire count is considered too #define EXPIRE_THRESHOLD 10 // A smaller expire count is considered too // chatty for the temporal expire messages #define EXPIRE_RATELIMIT 10 // maximum rate in seconds to report expiration class LogBufferElement { const log_id_t mLogId; Loading
logd/LogTimes.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ LogTimeEntry::LogTimeEntry(LogReader &reader, SocketClient *client, mRelease(false), mError(false), threadRunning(false), leadingDropped(false), mReader(reader), mLogMask(logMask), mPid(pid), Loading Loading @@ -123,6 +124,8 @@ void *LogTimeEntry::threadStart(void *obj) { bool privileged = FlushCommand::hasReadLogs(client); me->leadingDropped = true; lock(); while (me->threadRunning && !me->isError_Locked()) { Loading @@ -132,6 +135,7 @@ void *LogTimeEntry::threadStart(void *obj) { if (me->mTail) { logbuf.flushTo(client, start, privileged, FilterFirstPass, me); me->leadingDropped = true; } start = logbuf.flushTo(client, start, privileged, FilterSecondPass, me); Loading Loading @@ -163,6 +167,14 @@ int LogTimeEntry::FilterFirstPass(const LogBufferElement *element, void *obj) { LogTimeEntry::lock(); if (me->leadingDropped) { if (element->getDropped()) { LogTimeEntry::unlock(); return false; } me->leadingDropped = false; } if (me->mCount == 0) { me->mStart = element->getSequence(); } Loading Loading @@ -190,6 +202,13 @@ int LogTimeEntry::FilterSecondPass(const LogBufferElement *element, void *obj) { goto skip; } if (me->leadingDropped) { if (element->getDropped()) { goto skip; } me->leadingDropped = false; } // Truncate to close race between first and second pass if (me->mNonBlock && me->mTail && (me->mIndex >= me->mCount)) { goto stop; Loading
logd/LogTimes.h +1 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ class LogTimeEntry { bool mRelease; bool mError; bool threadRunning; bool leadingDropped; pthread_cond_t threadTriggeredCondition; pthread_t mThread; LogReader &mReader; Loading