From 7fd6c5c6f5f55e680a67cd9ca949f9c85b0ac0d0 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Tue, 19 Jan 2016 16:04:41 -0800 Subject: [PATCH] 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 --- logd/LogBuffer.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp index cdf5d08fb..9e0d4515b 100644 --- a/logd/LogBuffer.cpp +++ b/logd/LogBuffer.cpp @@ -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) {