Loading logd/LogBuffer.cpp +29 −27 Original line number Diff line number Diff line Loading @@ -109,11 +109,11 @@ void LogBuffer::init() { LogBuffer::LogBuffer(LastLogTimes* times) : monotonic(android_log_clockid() == CLOCK_MONOTONIC), mTimes(*times) { pthread_mutex_init(&mLogElementsLock, NULL); pthread_mutex_init(&mLogElementsLock, nullptr); log_id_for_each(i) { lastLoggedElements[i] = NULL; droppedElements[i] = NULL; lastLoggedElements[i] = nullptr; droppedElements[i] = nullptr; } init(); Loading Loading @@ -198,7 +198,7 @@ int LogBuffer::log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, new LogBufferElement(log_id, realtime, uid, pid, tid, msg, len); if (log_id != LOG_ID_SECURITY) { int prio = ANDROID_LOG_INFO; const char* tag = NULL; const char* tag = nullptr; if (log_id == LOG_ID_EVENTS) { tag = tagToName(elem->getTag()); } else { Loading @@ -224,24 +224,24 @@ int LogBuffer::log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, // // State Init // incoming: // dropped = NULL // currentLast = NULL; // dropped = nullptr // currentLast = nullptr; // elem = incoming message // outgoing: // dropped = NULL -> State 0 // dropped = nullptr -> State 0 // currentLast = copy of elem // log elem // State 0 // incoming: // count = 0 // dropped = NULL // dropped = nullptr // currentLast = copy of last message // elem = incoming message // outgoing: if match != DIFFERENT // dropped = copy of first identical message -> State 1 // currentLast = reference to elem // break: if match == DIFFERENT // dropped = NULL -> State 0 // dropped = nullptr -> State 0 // delete copy of last message (incoming currentLast) // currentLast = copy of elem // log elem Loading @@ -268,7 +268,7 @@ int LogBuffer::log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, // currentLast = reference to elem, sum liblog. // break: if match == DIFFERENT // delete dropped // dropped = NULL -> State 0 // dropped = nullptr -> State 0 // log reference to last held-back (currentLast) // currentLast = copy of elem // log elem Loading @@ -287,7 +287,7 @@ int LogBuffer::log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, // currentLast = reference to elem // break: if match == DIFFERENT // log dropped (chatty message) // dropped = NULL -> State 0 // dropped = nullptr -> State 0 // log reference to last held-back (currentLast) // currentLast = copy of elem // log elem Loading Loading @@ -352,7 +352,7 @@ int LogBuffer::log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, } else { // State 1 delete dropped; } droppedElements[log_id] = NULL; droppedElements[log_id] = nullptr; log(currentLast); // report last message in the series } else { // State 0 delete currentLast; Loading Loading @@ -656,7 +656,7 @@ class LogBufferElementLast { // mLogElementsLock must be held when this function is called. // bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { LogTimeEntry* oldest = NULL; LogTimeEntry* oldest = nullptr; bool busy = false; bool clearAll = pruneRows == ULONG_MAX; Loading Loading @@ -1078,9 +1078,11 @@ unsigned long LogBuffer::getSize(log_id_t id) { return retval; } log_time LogBuffer::flushTo( SocketClient* reader, const log_time& start, bool privileged, bool security, int (*filter)(const LogBufferElement* element, void* arg), void* arg) { log_time LogBuffer::flushTo(SocketClient* reader, const log_time& start, pid_t* lastTid, bool privileged, bool security, int (*filter)(const LogBufferElement* element, void* arg), void* arg) { LogBufferElementCollection::iterator it; uid_t uid = reader->getUid(); Loading Loading @@ -1109,9 +1111,6 @@ log_time LogBuffer::flushTo( } log_time max = start; // Help detect if the valid message before is from the same source so // we can differentiate chatty filter types. pid_t lastTid[LOG_ID_MAX] = { 0 }; for (; it != mLogElements.end(); ++it) { LogBufferElement* element = *it; Loading Loading @@ -1139,7 +1138,9 @@ log_time LogBuffer::flushTo( } } bool sameTid = lastTid[element->getLogId()] == element->getTid(); bool sameTid = false; if (lastTid) { sameTid = lastTid[element->getLogId()] == element->getTid(); // Dropped (chatty) immediately following a valid log from the // same source in the same log buffer indicates we have a // multiple identical squash. chatty that differs source Loading @@ -1147,6 +1148,7 @@ log_time LogBuffer::flushTo( // source is also due to spam filter. lastTid[element->getLogId()] = (element->getDropped() && !sameTid) ? 0 : element->getTid(); } pthread_mutex_unlock(&mLogElementsLock); Loading logd/LogBuffer.h +6 −2 Original line number Diff line number Diff line Loading @@ -115,11 +115,15 @@ class LogBuffer { int log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, pid_t tid, const char* msg, unsigned short len); // lastTid is an optional context to help detect if the last previous // valid message was from the same source so we can differentiate chatty // filter types (identical or expired) log_time flushTo(SocketClient* writer, const log_time& start, pid_t* lastTid, // &lastTid[LOG_ID_MAX] or nullptr bool privileged, bool security, int (*filter)(const LogBufferElement* element, void* arg) = NULL, void* arg = NULL); void* arg) = nullptr, void* arg = nullptr); bool clear(log_id_t id, uid_t uid = AID_ROOT); unsigned long getSize(log_id_t id); Loading logd/LogBufferElement.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -235,7 +235,9 @@ log_time LogBufferElement::flushTo(SocketClient* reader, LogBuffer* parent, } iovec[1].iov_len = entry.len; log_time retval = reader->sendDatav(iovec, 2) ? FLUSH_ERROR : mRealTime; log_time retval = reader->sendDatav(iovec, 1 + (entry.len != 0)) ? FLUSH_ERROR : mRealTime; if (buffer) free(buffer); Loading logd/LogReader.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -182,7 +182,7 @@ bool LogReader::onDataAvailable(SocketClient* cli) { } logFindStart(pid, logMask, sequence, logbuf().isMonotonic() && android::isMonotonic(start)); logbuf().flushTo(cli, sequence, FlushCommand::hasReadLogs(cli), logbuf().flushTo(cli, sequence, nullptr, FlushCommand::hasReadLogs(cli), FlushCommand::hasSecurityLogs(cli), logFindStart.callback, &logFindStart); Loading logd/LogTimes.cpp +11 −11 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #include <errno.h> #include <string.h> #include <sys/prctl.h> #include <private/android_logger.h> Loading Loading @@ -47,7 +48,8 @@ LogTimeEntry::LogTimeEntry(LogReader& reader, SocketClient* client, mEnd(log_time(android_log_clockid())) { mTimeout.tv_sec = timeout / NS_PER_SEC; mTimeout.tv_nsec = timeout % NS_PER_SEC; pthread_cond_init(&threadTriggeredCondition, NULL); memset(mLastTid, 0, sizeof(mLastTid)); pthread_cond_init(&threadTriggeredCondition, nullptr); cleanSkip_Locked(); } Loading Loading @@ -98,7 +100,7 @@ void LogTimeEntry::threadStop(void* obj) { it++; } me->mClient = NULL; me->mClient = nullptr; reader.release(client); } Loading @@ -122,7 +124,7 @@ void* LogTimeEntry::threadStart(void* obj) { SocketClient* client = me->mClient; if (!client) { me->error(); return NULL; return nullptr; } LogBuffer& logbuf = me->mReader.logbuf(); Loading Loading @@ -151,12 +153,12 @@ void* LogTimeEntry::threadStart(void* obj) { unlock(); if (me->mTail) { logbuf.flushTo(client, start, privileged, security, FilterFirstPass, me); logbuf.flushTo(client, start, nullptr, privileged, security, FilterFirstPass, me); me->leadingDropped = true; } start = logbuf.flushTo(client, start, privileged, security, FilterSecondPass, me); start = logbuf.flushTo(client, start, me->mLastTid, privileged, security, FilterSecondPass, me); lock(); Loading @@ -182,7 +184,7 @@ void* LogTimeEntry::threadStart(void* obj) { pthread_cleanup_pop(true); return NULL; return nullptr; } // A first pass to count the number of elements Loading Loading @@ -281,7 +283,5 @@ stop: } void LogTimeEntry::cleanSkip_Locked(void) { for (log_id_t i = LOG_ID_MIN; i < LOG_ID_MAX; i = (log_id_t)(i + 1)) { skipAhead[i] = 0; } memset(skipAhead, 0, sizeof(skipAhead)); } Loading
logd/LogBuffer.cpp +29 −27 Original line number Diff line number Diff line Loading @@ -109,11 +109,11 @@ void LogBuffer::init() { LogBuffer::LogBuffer(LastLogTimes* times) : monotonic(android_log_clockid() == CLOCK_MONOTONIC), mTimes(*times) { pthread_mutex_init(&mLogElementsLock, NULL); pthread_mutex_init(&mLogElementsLock, nullptr); log_id_for_each(i) { lastLoggedElements[i] = NULL; droppedElements[i] = NULL; lastLoggedElements[i] = nullptr; droppedElements[i] = nullptr; } init(); Loading Loading @@ -198,7 +198,7 @@ int LogBuffer::log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, new LogBufferElement(log_id, realtime, uid, pid, tid, msg, len); if (log_id != LOG_ID_SECURITY) { int prio = ANDROID_LOG_INFO; const char* tag = NULL; const char* tag = nullptr; if (log_id == LOG_ID_EVENTS) { tag = tagToName(elem->getTag()); } else { Loading @@ -224,24 +224,24 @@ int LogBuffer::log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, // // State Init // incoming: // dropped = NULL // currentLast = NULL; // dropped = nullptr // currentLast = nullptr; // elem = incoming message // outgoing: // dropped = NULL -> State 0 // dropped = nullptr -> State 0 // currentLast = copy of elem // log elem // State 0 // incoming: // count = 0 // dropped = NULL // dropped = nullptr // currentLast = copy of last message // elem = incoming message // outgoing: if match != DIFFERENT // dropped = copy of first identical message -> State 1 // currentLast = reference to elem // break: if match == DIFFERENT // dropped = NULL -> State 0 // dropped = nullptr -> State 0 // delete copy of last message (incoming currentLast) // currentLast = copy of elem // log elem Loading @@ -268,7 +268,7 @@ int LogBuffer::log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, // currentLast = reference to elem, sum liblog. // break: if match == DIFFERENT // delete dropped // dropped = NULL -> State 0 // dropped = nullptr -> State 0 // log reference to last held-back (currentLast) // currentLast = copy of elem // log elem Loading @@ -287,7 +287,7 @@ int LogBuffer::log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, // currentLast = reference to elem // break: if match == DIFFERENT // log dropped (chatty message) // dropped = NULL -> State 0 // dropped = nullptr -> State 0 // log reference to last held-back (currentLast) // currentLast = copy of elem // log elem Loading Loading @@ -352,7 +352,7 @@ int LogBuffer::log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, } else { // State 1 delete dropped; } droppedElements[log_id] = NULL; droppedElements[log_id] = nullptr; log(currentLast); // report last message in the series } else { // State 0 delete currentLast; Loading Loading @@ -656,7 +656,7 @@ class LogBufferElementLast { // mLogElementsLock must be held when this function is called. // bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { LogTimeEntry* oldest = NULL; LogTimeEntry* oldest = nullptr; bool busy = false; bool clearAll = pruneRows == ULONG_MAX; Loading Loading @@ -1078,9 +1078,11 @@ unsigned long LogBuffer::getSize(log_id_t id) { return retval; } log_time LogBuffer::flushTo( SocketClient* reader, const log_time& start, bool privileged, bool security, int (*filter)(const LogBufferElement* element, void* arg), void* arg) { log_time LogBuffer::flushTo(SocketClient* reader, const log_time& start, pid_t* lastTid, bool privileged, bool security, int (*filter)(const LogBufferElement* element, void* arg), void* arg) { LogBufferElementCollection::iterator it; uid_t uid = reader->getUid(); Loading Loading @@ -1109,9 +1111,6 @@ log_time LogBuffer::flushTo( } log_time max = start; // Help detect if the valid message before is from the same source so // we can differentiate chatty filter types. pid_t lastTid[LOG_ID_MAX] = { 0 }; for (; it != mLogElements.end(); ++it) { LogBufferElement* element = *it; Loading Loading @@ -1139,7 +1138,9 @@ log_time LogBuffer::flushTo( } } bool sameTid = lastTid[element->getLogId()] == element->getTid(); bool sameTid = false; if (lastTid) { sameTid = lastTid[element->getLogId()] == element->getTid(); // Dropped (chatty) immediately following a valid log from the // same source in the same log buffer indicates we have a // multiple identical squash. chatty that differs source Loading @@ -1147,6 +1148,7 @@ log_time LogBuffer::flushTo( // source is also due to spam filter. lastTid[element->getLogId()] = (element->getDropped() && !sameTid) ? 0 : element->getTid(); } pthread_mutex_unlock(&mLogElementsLock); Loading
logd/LogBuffer.h +6 −2 Original line number Diff line number Diff line Loading @@ -115,11 +115,15 @@ class LogBuffer { int log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, pid_t tid, const char* msg, unsigned short len); // lastTid is an optional context to help detect if the last previous // valid message was from the same source so we can differentiate chatty // filter types (identical or expired) log_time flushTo(SocketClient* writer, const log_time& start, pid_t* lastTid, // &lastTid[LOG_ID_MAX] or nullptr bool privileged, bool security, int (*filter)(const LogBufferElement* element, void* arg) = NULL, void* arg = NULL); void* arg) = nullptr, void* arg = nullptr); bool clear(log_id_t id, uid_t uid = AID_ROOT); unsigned long getSize(log_id_t id); Loading
logd/LogBufferElement.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -235,7 +235,9 @@ log_time LogBufferElement::flushTo(SocketClient* reader, LogBuffer* parent, } iovec[1].iov_len = entry.len; log_time retval = reader->sendDatav(iovec, 2) ? FLUSH_ERROR : mRealTime; log_time retval = reader->sendDatav(iovec, 1 + (entry.len != 0)) ? FLUSH_ERROR : mRealTime; if (buffer) free(buffer); Loading
logd/LogReader.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -182,7 +182,7 @@ bool LogReader::onDataAvailable(SocketClient* cli) { } logFindStart(pid, logMask, sequence, logbuf().isMonotonic() && android::isMonotonic(start)); logbuf().flushTo(cli, sequence, FlushCommand::hasReadLogs(cli), logbuf().flushTo(cli, sequence, nullptr, FlushCommand::hasReadLogs(cli), FlushCommand::hasSecurityLogs(cli), logFindStart.callback, &logFindStart); Loading
logd/LogTimes.cpp +11 −11 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #include <errno.h> #include <string.h> #include <sys/prctl.h> #include <private/android_logger.h> Loading Loading @@ -47,7 +48,8 @@ LogTimeEntry::LogTimeEntry(LogReader& reader, SocketClient* client, mEnd(log_time(android_log_clockid())) { mTimeout.tv_sec = timeout / NS_PER_SEC; mTimeout.tv_nsec = timeout % NS_PER_SEC; pthread_cond_init(&threadTriggeredCondition, NULL); memset(mLastTid, 0, sizeof(mLastTid)); pthread_cond_init(&threadTriggeredCondition, nullptr); cleanSkip_Locked(); } Loading Loading @@ -98,7 +100,7 @@ void LogTimeEntry::threadStop(void* obj) { it++; } me->mClient = NULL; me->mClient = nullptr; reader.release(client); } Loading @@ -122,7 +124,7 @@ void* LogTimeEntry::threadStart(void* obj) { SocketClient* client = me->mClient; if (!client) { me->error(); return NULL; return nullptr; } LogBuffer& logbuf = me->mReader.logbuf(); Loading Loading @@ -151,12 +153,12 @@ void* LogTimeEntry::threadStart(void* obj) { unlock(); if (me->mTail) { logbuf.flushTo(client, start, privileged, security, FilterFirstPass, me); logbuf.flushTo(client, start, nullptr, privileged, security, FilterFirstPass, me); me->leadingDropped = true; } start = logbuf.flushTo(client, start, privileged, security, FilterSecondPass, me); start = logbuf.flushTo(client, start, me->mLastTid, privileged, security, FilterSecondPass, me); lock(); Loading @@ -182,7 +184,7 @@ void* LogTimeEntry::threadStart(void* obj) { pthread_cleanup_pop(true); return NULL; return nullptr; } // A first pass to count the number of elements Loading Loading @@ -281,7 +283,5 @@ stop: } void LogTimeEntry::cleanSkip_Locked(void) { for (log_id_t i = LOG_ID_MIN; i < LOG_ID_MAX; i = (log_id_t)(i + 1)) { skipAhead[i] = 0; } memset(skipAhead, 0, sizeof(skipAhead)); }