Loading logd/LogBuffer.cpp +13 −2 Original line number Original line Diff line number Diff line Loading @@ -222,6 +222,9 @@ LogBufferElementCollection::iterator LogBuffer::erase( LogBufferElement *element = *it; LogBufferElement *element = *it; log_id_t id = element->getLogId(); log_id_t id = element->getLogId(); // Remove iterator references in the various lists that will become stale // after the element is erased from the main logging list. { // start of scope for found iterator { // start of scope for found iterator int key = ((id == LOG_ID_EVENTS) || (id == LOG_ID_SECURITY)) ? int key = ((id == LOG_ID_EVENTS) || (id == LOG_ID_SECURITY)) ? element->getTag() : element->getUid(); element->getTag() : element->getUid(); Loading @@ -231,7 +234,8 @@ LogBufferElementCollection::iterator LogBuffer::erase( } } } } if ((id != LOG_ID_EVENTS) && (id != LOG_ID_SECURITY) && (element->getUid() == AID_SYSTEM)) { if ((id != LOG_ID_EVENTS) && (id != LOG_ID_SECURITY)) { // element->getUid() may not be AID_SYSTEM for next-best-watermark. // start of scope for pid found iterator // start of scope for pid found iterator LogBufferPidIteratorMap::iterator found = LogBufferPidIteratorMap::iterator found = mLastWorstPidOfSystem[id].find(element->getPid()); mLastWorstPidOfSystem[id].find(element->getPid()); Loading Loading @@ -501,7 +505,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { it = found->second; it = found->second; } } } } if (worstPid) { if (worstPid) { // Only set if !LOG_ID_EVENTS and !LOG_ID_SECURITY // begin scope for pid worst found iterator // begin scope for pid worst found iterator LogBufferPidIteratorMap::iterator found LogBufferPidIteratorMap::iterator found = mLastWorstPidOfSystem[id].find(worstPid); = mLastWorstPidOfSystem[id].find(worstPid); Loading Loading @@ -534,6 +538,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { ++it; ++it; continue; continue; } } // below this point element->getLogId() == id if (leading && (!mLastSet[id] || ((*mLast[id])->getLogId() != id))) { if (leading && (!mLastSet[id] || ((*mLast[id])->getLogId() != id))) { mLast[id] = it; mLast[id] = it; Loading Loading @@ -590,6 +595,8 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { && ((!gc && (element->getPid() == worstPid)) && ((!gc && (element->getPid() == worstPid)) || (mLastWorstPidOfSystem[id].find(element->getPid()) || (mLastWorstPidOfSystem[id].find(element->getPid()) == mLastWorstPidOfSystem[id].end()))) { == mLastWorstPidOfSystem[id].end()))) { // element->getUid() may not be AID_SYSTEM, next best // watermark if current one empty. mLastWorstPidOfSystem[id][element->getPid()] = it; mLastWorstPidOfSystem[id][element->getPid()] = it; } } if ((!gc && !worstPid && (key == worst)) if ((!gc && !worstPid && (key == worst)) Loading @@ -607,6 +614,8 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { ++it; ++it; continue; continue; } } // key == worst below here // If worstPid set, then element->getPid() == worstPid below here pruneRows--; pruneRows--; if (pruneRows == 0) { if (pruneRows == 0) { Loading @@ -630,6 +639,8 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { if (worstPid && (!gc if (worstPid && (!gc || (mLastWorstPidOfSystem[id].find(worstPid) || (mLastWorstPidOfSystem[id].find(worstPid) == mLastWorstPidOfSystem[id].end()))) { == mLastWorstPidOfSystem[id].end()))) { // element->getUid() may not be AID_SYSTEM, next best // watermark if current one empty. mLastWorstPidOfSystem[id][worstPid] = it; mLastWorstPidOfSystem[id][worstPid] = it; } } if ((!gc && !worstPid) || if ((!gc && !worstPid) || Loading Loading
logd/LogBuffer.cpp +13 −2 Original line number Original line Diff line number Diff line Loading @@ -222,6 +222,9 @@ LogBufferElementCollection::iterator LogBuffer::erase( LogBufferElement *element = *it; LogBufferElement *element = *it; log_id_t id = element->getLogId(); log_id_t id = element->getLogId(); // Remove iterator references in the various lists that will become stale // after the element is erased from the main logging list. { // start of scope for found iterator { // start of scope for found iterator int key = ((id == LOG_ID_EVENTS) || (id == LOG_ID_SECURITY)) ? int key = ((id == LOG_ID_EVENTS) || (id == LOG_ID_SECURITY)) ? element->getTag() : element->getUid(); element->getTag() : element->getUid(); Loading @@ -231,7 +234,8 @@ LogBufferElementCollection::iterator LogBuffer::erase( } } } } if ((id != LOG_ID_EVENTS) && (id != LOG_ID_SECURITY) && (element->getUid() == AID_SYSTEM)) { if ((id != LOG_ID_EVENTS) && (id != LOG_ID_SECURITY)) { // element->getUid() may not be AID_SYSTEM for next-best-watermark. // start of scope for pid found iterator // start of scope for pid found iterator LogBufferPidIteratorMap::iterator found = LogBufferPidIteratorMap::iterator found = mLastWorstPidOfSystem[id].find(element->getPid()); mLastWorstPidOfSystem[id].find(element->getPid()); Loading Loading @@ -501,7 +505,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { it = found->second; it = found->second; } } } } if (worstPid) { if (worstPid) { // Only set if !LOG_ID_EVENTS and !LOG_ID_SECURITY // begin scope for pid worst found iterator // begin scope for pid worst found iterator LogBufferPidIteratorMap::iterator found LogBufferPidIteratorMap::iterator found = mLastWorstPidOfSystem[id].find(worstPid); = mLastWorstPidOfSystem[id].find(worstPid); Loading Loading @@ -534,6 +538,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { ++it; ++it; continue; continue; } } // below this point element->getLogId() == id if (leading && (!mLastSet[id] || ((*mLast[id])->getLogId() != id))) { if (leading && (!mLastSet[id] || ((*mLast[id])->getLogId() != id))) { mLast[id] = it; mLast[id] = it; Loading Loading @@ -590,6 +595,8 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { && ((!gc && (element->getPid() == worstPid)) && ((!gc && (element->getPid() == worstPid)) || (mLastWorstPidOfSystem[id].find(element->getPid()) || (mLastWorstPidOfSystem[id].find(element->getPid()) == mLastWorstPidOfSystem[id].end()))) { == mLastWorstPidOfSystem[id].end()))) { // element->getUid() may not be AID_SYSTEM, next best // watermark if current one empty. mLastWorstPidOfSystem[id][element->getPid()] = it; mLastWorstPidOfSystem[id][element->getPid()] = it; } } if ((!gc && !worstPid && (key == worst)) if ((!gc && !worstPid && (key == worst)) Loading @@ -607,6 +614,8 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { ++it; ++it; continue; continue; } } // key == worst below here // If worstPid set, then element->getPid() == worstPid below here pruneRows--; pruneRows--; if (pruneRows == 0) { if (pruneRows == 0) { Loading @@ -630,6 +639,8 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { if (worstPid && (!gc if (worstPid && (!gc || (mLastWorstPidOfSystem[id].find(worstPid) || (mLastWorstPidOfSystem[id].find(worstPid) == mLastWorstPidOfSystem[id].end()))) { == mLastWorstPidOfSystem[id].end()))) { // element->getUid() may not be AID_SYSTEM, next best // watermark if current one empty. mLastWorstPidOfSystem[id][worstPid] = it; mLastWorstPidOfSystem[id][worstPid] = it; } } if ((!gc && !worstPid) || if ((!gc && !worstPid) || Loading