summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2015-04-23 14:51:26 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-04-23 14:51:26 +0000
commit92391131c43ec59d174d95ccfab6944832d1cee7 (patch)
tree88378c89fdf9c9a3be6318af8f14a08346483fd1
parent8a457c79276c65d1cc30fea929916986756a00b7 (diff)
parentf94727b4c6b10be576e145415bd6493a5e81c4a1 (diff)
downloadsystem_core-92391131c43ec59d174d95ccfab6944832d1cee7.zip
system_core-92391131c43ec59d174d95ccfab6944832d1cee7.tar.gz
system_core-92391131c43ec59d174d95ccfab6944832d1cee7.tar.bz2
am f94727b4: am 40502e1a: Merge "logd: ratelimit drop messages to 1/sec"
* commit 'f94727b4c6b10be576e145415bd6493a5e81c4a1': logd: ratelimit drop messages to 1/sec
-rw-r--r--logd/LogBuffer.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index 1859461..83a6b1d 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -247,7 +247,7 @@ public:
uint64_t getKey() { return value; }
};
-struct LogBufferElementEntry {
+class LogBufferElementEntry {
const uint64_t key;
LogBufferElement *last;
@@ -259,8 +259,9 @@ public:
LogBufferElement *getLast() { return last; }
};
-struct LogBufferElementLast : public android::BasicHashtable<uint64_t, LogBufferElementEntry> {
+class LogBufferElementLast : public android::BasicHashtable<uint64_t, LogBufferElementEntry> {
+public:
bool merge(LogBufferElement *e, unsigned short dropped) {
LogBufferElementKey key(e->getUid(), e->getPid(), e->getTid());
android::hash_t hash = android::hash_type(key.getKey());
@@ -286,6 +287,21 @@ struct LogBufferElementLast : public android::BasicHashtable<uint64_t, LogBuffer
add(hash, LogBufferElementEntry(key.getKey(), e));
}
+ inline void clear() {
+ android::BasicHashtable<uint64_t, LogBufferElementEntry>::clear();
+ }
+
+ void clear(LogBufferElement *e) {
+ uint64_t current = e->getRealTime().nsec() - NS_PER_SEC;
+ ssize_t index = -1;
+ while((index = next(index)) >= 0) {
+ if (current > editEntryAt(index).getLast()->getRealTime().nsec()) {
+ removeAt(index);
+ index = -1;
+ }
+ }
+ }
+
};
// prune "pruneRows" of type "id" from the buffer.
@@ -395,7 +411,7 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
leading = false;
if (hasBlacklist && mPrune.naughty(e)) {
- last.clear();
+ last.clear(e);
it = erase(it);
if (dropped) {
continue;
@@ -423,7 +439,7 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
}
if (e->getUid() != worst) {
- last.clear();
+ last.clear(e);
++it;
continue;
}