Revert "logd: drop mSequence from LogBufferElement"
This reverts commit d18255f353fe9db870dcc6b01e5a2dcc687ea649.
There is a long standing bug that logd will leak memory during its
prune process if the time on the device changes significantly forwards
then backwards. This is due to using the timestamp of each log
message to determine what log messages are yet to be processed by a
reader thread.
Various attempts have been made to rectify this, but the only solution
that safely fixes this issue is to go back to using sequence numbers
on the log messages.
Bug: 64675203
Bug: 77971811
Bug: 149340579
Bug: 150923384
Test: logcat output looks sane
Change-Id: Ibce79cf184eb29a4914f3e42a8cb2868d04dc165
diff --git a/logd/LogTimes.cpp b/logd/LogTimes.cpp
index 1723139..1d8d5fc 100644
--- a/logd/LogTimes.cpp
+++ b/logd/LogTimes.cpp
@@ -18,8 +18,6 @@
#include <string.h>
#include <sys/prctl.h>
-#include <private/android_logger.h>
-
#include "FlushCommand.h"
#include "LogBuffer.h"
#include "LogReader.h"
@@ -28,7 +26,7 @@
pthread_mutex_t LogTimeEntry::timesLock = PTHREAD_MUTEX_INITIALIZER;
LogTimeEntry::LogTimeEntry(LogReader& reader, SocketClient* client, bool nonBlock,
- unsigned long tail, log_mask_t logMask, pid_t pid, log_time start,
+ unsigned long tail, log_mask_t logMask, pid_t pid, uint64_t start,
uint64_t timeout)
: leadingDropped(false),
mReader(reader),
@@ -80,7 +78,7 @@
wrlock();
- log_time start = me->mStart;
+ uint64_t start = me->mStart;
while (!me->mRelease) {
if (me->mTimeout.tv_sec || me->mTimeout.tv_nsec) {
@@ -110,7 +108,7 @@
break;
}
- me->mStart = start + log_time(0, 1);
+ me->mStart = start + 1;
if (me->mNonBlock || me->mRelease) {
break;
@@ -157,7 +155,7 @@
}
if (me->mCount == 0) {
- me->mStart = element->getRealTime();
+ me->mStart = element->getSequence();
}
if ((!me->mPid || (me->mPid == element->getPid())) &&
@@ -176,7 +174,7 @@
LogTimeEntry::wrlock();
- me->mStart = element->getRealTime();
+ me->mStart = element->getSequence();
if (me->skipAhead[element->getLogId()]) {
me->skipAhead[element->getLogId()]--;