logd: prune maintain per-id watermark (part deux)

iterator corruption as we allow mLast to slip through the FIFO

Bug: 23685592
Bug: 26646087
Change-Id: Ifcbaecf390ee47b195c3d823d080c66c15db4530
This commit is contained in:
Mark Salyzyn 2016-01-19 16:04:41 -08:00
parent d0009911de
commit 7fd6c5c6f5

View file

@ -332,13 +332,21 @@ LogBufferElementCollection::iterator LogBuffer::erase(
}
}
bool setLast = mLastSet[id] && (it == mLast[id]);
bool setLast[LOG_ID_MAX];
bool doSetLast = false;
log_id_for_each(i) {
doSetLast |= setLast[i] = mLastSet[i] && (it == mLast[i]);
}
it = mLogElements.erase(it);
if (setLast) {
if (it == mLogElements.end()) { // unlikely
mLastSet[id] = false;
} else {
mLast[id] = it;
if (doSetLast) {
log_id_for_each(i) {
if (setLast[i]) {
if (it == mLogElements.end()) { // unlikely
mLastSet[i] = false;
} else {
mLast[i] = it;
}
}
}
}
if (coalesce) {