Merge "Make init re-exec itself for its SELinux domain transition."
diff --git a/liblog/log_is_loggable.c b/liblog/log_is_loggable.c
index df67123..2e09192 100644
--- a/liblog/log_is_loggable.c
+++ b/liblog/log_is_loggable.c
@@ -28,7 +28,7 @@
return def;
}
{
- static const char log_namespace[] = "log.tag.";
+ static const char log_namespace[] = "persist.log.tag.";
char key[sizeof(log_namespace) + strlen(tag)];
strcpy(key, log_namespace);
@@ -37,6 +37,9 @@
if (__system_property_get(key + 8, buf) <= 0) {
buf[0] = '\0';
}
+ if (!buf[0] && __system_property_get(key, buf) <= 0) {
+ buf[0] = '\0';
+ }
}
switch (toupper(buf[0])) {
case 'V': return ANDROID_LOG_VERBOSE;
@@ -53,17 +56,6 @@
int __android_log_is_loggable(int prio, const char *tag, int def)
{
- static char user;
- int logLevel;
-
- if (user == 0) {
- char buf[PROP_VALUE_MAX];
- if (__system_property_get("ro.build.type", buf) <= 0) {
- buf[0] = '\0';
- }
- user = strcmp(buf, "user") ? -1 : 1;
- }
-
- logLevel = (user == 1) ? def : __android_log_level(tag, def);
+ int logLevel = __android_log_level(tag, def);
return logLevel >= 0 && prio >= logLevel;
}
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index 1859461..1dced11 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -247,7 +247,7 @@
uint64_t getKey() { return value; }
};
-struct LogBufferElementEntry {
+class LogBufferElementEntry {
const uint64_t key;
LogBufferElement *last;
@@ -259,8 +259,9 @@
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 @@
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.
@@ -349,9 +365,16 @@
if (sorted.get()) {
if (sorted[0] && sorted[1]) {
- worst = sorted[0]->getKey();
worst_sizes = sorted[0]->getSizes();
- second_worst_sizes = sorted[1]->getSizes();
+ // Calculate threshold as 12.5% of available storage
+ size_t threshold = log_buffer_size(id) / 8;
+ if (worst_sizes > threshold) {
+ worst = sorted[0]->getKey();
+ second_worst_sizes = sorted[1]->getSizes();
+ if (second_worst_sizes < threshold) {
+ second_worst_sizes = threshold;
+ }
+ }
}
}
}
@@ -395,7 +418,7 @@
leading = false;
if (hasBlacklist && mPrune.naughty(e)) {
- last.clear();
+ last.clear(e);
it = erase(it);
if (dropped) {
continue;
@@ -423,7 +446,7 @@
}
if (e->getUid() != worst) {
- last.clear();
+ last.clear(e);
++it;
continue;
}
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 4d9c4f3..c00c590 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -155,6 +155,7 @@
# Load properties from /system/ + /factory after fs mount.
on load_all_props_action
load_all_props
+ start logd
start logd-reinit
# Indicate to fw loaders that the relevant mounts are up.
@@ -438,6 +439,7 @@
on property:vold.decrypt=trigger_load_persist_props
load_persist_props
+ start logd
start logd-reinit
on property:vold.decrypt=trigger_post_fs_data
@@ -483,7 +485,6 @@
socket logdw dgram 0222 logd logd
service logd-reinit /system/bin/logd --reinit
- start logd
oneshot
disabled