Skip to content

Commit

Permalink
logd: worst uid record watermark part four
Browse files Browse the repository at this point in the history
(cherry pick from commit 831aa29)

With part deux we caused an apparent regression by not checking for
stale recorded iterators. This checking was on-purpose bypassesed
when leading prune entries were to be deleted without touching the
statistics engine due to an in-place merge.

Part deux had us leaving iterators we were not focussed on untouched
which in turn because they were left behind, had a much higher
likelihood of being deleted without touching the statistics engine.

Perform the check every delete.

Bug: 23789348
Bug: 23490267
Change-Id: Idc6cc23d1f9e3b6cd9a083139a0de59479fbfe08
  • Loading branch information
Mark Salyzyn committed Sep 4, 2015
1 parent d9a06af commit 4ee37bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
17 changes: 9 additions & 8 deletions logd/LogBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ void LogBuffer::maybePrune(log_id_t id) {
}
}

LogBufferElementCollection::iterator LogBuffer::erase(LogBufferElementCollection::iterator it) {
LogBufferElementCollection::iterator LogBuffer::erase(
LogBufferElementCollection::iterator it, bool engageStats) {
LogBufferElement *e = *it;
log_id_t id = e->getLogId();
LogBufferIteratorMap::iterator f = mLastWorstUid[id].find(e->getUid());
Expand All @@ -247,7 +248,11 @@ LogBufferElementCollection::iterator LogBuffer::erase(LogBufferElementCollection
mLastWorstUid[id].erase(f);
}
it = mLogElements.erase(it);
stats.subtract(e);
if (engageStats) {
stats.subtract(e);
} else {
stats.erase(e);
}
delete e;

return it;
Expand Down Expand Up @@ -442,9 +447,7 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {

// merge any drops
if (dropped && last.merge(e, dropped)) {
it = mLogElements.erase(it);
stats.erase(e);
delete e;
it = erase(it, false);
continue;
}

Expand Down Expand Up @@ -510,9 +513,7 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
stats.drop(e);
e->setDropped(1);
if (last.merge(e, 1)) {
it = mLogElements.erase(it);
stats.erase(e);
delete e;
it = erase(it, false);
} else {
last.add(e);
mLastWorstUid[id][e->getUid()] = it;
Expand Down
3 changes: 2 additions & 1 deletion logd/LogBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ class LogBuffer {
private:
void maybePrune(log_id_t id);
void prune(log_id_t id, unsigned long pruneRows, uid_t uid = AID_ROOT);
LogBufferElementCollection::iterator erase(LogBufferElementCollection::iterator it);
LogBufferElementCollection::iterator erase(
LogBufferElementCollection::iterator it, bool engageStats = true);
};

#endif // _LOGD_LOG_BUFFER_H__

0 comments on commit 4ee37bc

Please sign in to comment.