Loading logd/LogBuffer.cpp +21 −1 Original line number Diff line number Diff line Loading @@ -295,7 +295,8 @@ public: ssize_t index = -1; while((index = next(index)) >= 0) { LogBufferElement *l = editEntryAt(index).getLast(); if ((l->getDropped() >= 4) && (current > l->getRealTime().nsec())) { if ((l->getDropped() >= EXPIRE_THRESHOLD) && (current > l->getRealTime().nsec())) { removeAt(index); index = -1; } Loading Loading @@ -387,6 +388,7 @@ 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; Loading Loading @@ -446,11 +448,29 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { } if (e->getUid() != worst) { if (start != log_time::EPOCH) { static const timespec too_old = { EXPIRE_HOUR_THRESHOLD * 60 * 60, 0 }; start = e->getRealTime() + too_old; } 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; Loading logd/LogBufferElement.h +5 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,11 @@ static inline bool worstUidEnabledForLogid(log_id_t id) { class LogBuffer; #define EXPIRE_HOUR_THRESHOLD 24 // Only expire chatty UID logs to preserve // non-chatty UIDs less than this age in hours #define EXPIRE_THRESHOLD 4 // A smaller expire count is considered too // chatty for the temporal expire messages class LogBufferElement { const log_id_t mLogId; const uid_t mUid; Loading Loading
logd/LogBuffer.cpp +21 −1 Original line number Diff line number Diff line Loading @@ -295,7 +295,8 @@ public: ssize_t index = -1; while((index = next(index)) >= 0) { LogBufferElement *l = editEntryAt(index).getLast(); if ((l->getDropped() >= 4) && (current > l->getRealTime().nsec())) { if ((l->getDropped() >= EXPIRE_THRESHOLD) && (current > l->getRealTime().nsec())) { removeAt(index); index = -1; } Loading Loading @@ -387,6 +388,7 @@ 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; Loading Loading @@ -446,11 +448,29 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { } if (e->getUid() != worst) { if (start != log_time::EPOCH) { static const timespec too_old = { EXPIRE_HOUR_THRESHOLD * 60 * 60, 0 }; start = e->getRealTime() + too_old; } 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; Loading
logd/LogBufferElement.h +5 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,11 @@ static inline bool worstUidEnabledForLogid(log_id_t id) { class LogBuffer; #define EXPIRE_HOUR_THRESHOLD 24 // Only expire chatty UID logs to preserve // non-chatty UIDs less than this age in hours #define EXPIRE_THRESHOLD 4 // A smaller expire count is considered too // chatty for the temporal expire messages class LogBufferElement { const log_id_t mLogId; const uid_t mUid; Loading