summaryrefslogtreecommitdiffstats
path: root/logd
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2015-06-01 09:41:19 -0700
committerMark Salyzyn <salyzyn@google.com>2015-06-01 14:27:02 -0700
commitfbf96b55d98e9042fe6f240fbcf3103faca8650d (patch)
tree3808da4f0395fe5c2946f975a5f822418e90fbce /logd
parentd4bdb7df9ba0003c69efec53dea3c4d56178fcbf (diff)
downloadsystem_core-fbf96b55d98e9042fe6f240fbcf3103faca8650d.zip
system_core-fbf96b55d98e9042fe6f240fbcf3103faca8650d.tar.gz
system_core-fbf96b55d98e9042fe6f240fbcf3103faca8650d.tar.bz2
logd: KISS & fix preserve a day
(cherry pick from commit 5921276a16528bf79292e828080bf0ec984cbb23) Code in 833a9b1e38ce65f2cdf3ebd095aaa99a92eb9467 was borken, simpler approach is to simply check last entry (to save a syscall) minus EXPIRE_HOUR_THRESHOLD. This does make longer logs less likely to call upon the spam detection than the algorithm being replaced, but sadly we ended up with a log entry in the future at the beginning of the logs confounding the previous algorithm. Bug: 21555259 Change-Id: I04fad67e95c8496521dbabb73b5f32c19d6a16c2
Diffstat (limited to 'logd')
-rw-r--r--logd/LogBuffer.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index d89a2e7..913e1f1 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -388,7 +388,6 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
bool kick = false;
bool leading = true;
LogBufferElementLast last;
- log_time start(log_time::EPOCH);
for(it = mLogElements.begin(); it != mLogElements.end();) {
LogBufferElement *e = *it;
@@ -446,30 +445,24 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
}
if (e->getUid() != worst) {
- leading = false;
- if (start != log_time::EPOCH) {
+ if (leading) {
static const timespec too_old = {
EXPIRE_HOUR_THRESHOLD * 60 * 60, 0
};
- start = e->getRealTime() + too_old;
+ LogBufferElementCollection::iterator last;
+ last = mLogElements.end();
+ --last;
+ if ((e->getRealTime() < ((*last)->getRealTime() - too_old))
+ || (e->getRealTime() > (*last)->getRealTime())) {
+ break;
+ }
}
+ leading = false;
last.clear(e);
++it;
continue;
}
- if ((start != log_time::EPOCH) && (e->getRealTime() > start)) {
- // KISS. Really a heuristic rather than algorithmically strong,
- // a crude mechanism, the following loops will move the oldest
- // watermark possibly wiping out the extra EXPIRE_HOUR_THRESHOLD
- // we just thought we were preserving. We count on the typical
- // pruneRows of 10% of total not being a sledgehammer.
- // A stronger algorithm would have us loop back to the top if
- // we have worst-UID enabled and we start expiring messages
- // below less than EXPIRE_HOUR_THRESHOLD old.
- break;
- }
-
pruneRows--;
if (pruneRows == 0) {
break;