Snap for 7224597 from 1b96cbd366a042b0f00e6978427c8123024becf5 to sdk-release
Change-Id: I5ba99ef4e355669550d153a4728feccec89a7128
diff --git a/include/android-base/properties.h b/include/android-base/properties.h
index 0f208ec..021f466 100644
--- a/include/android-base/properties.h
+++ b/include/android-base/properties.h
@@ -97,8 +97,8 @@
};
#endif
-static inline int TimeoutMultiplier() {
- return android::base::GetIntProperty("ro.timeout_multiplier", 1);
+static inline int HwTimeoutMultiplier() {
+ return android::base::GetIntProperty("ro.hw_timeout_multiplier", 1);
}
} // namespace base
diff --git a/logging.cpp b/logging.cpp
index 54f3fcc..4942e2f 100644
--- a/logging.cpp
+++ b/logging.cpp
@@ -32,10 +32,6 @@
#include <errno.h>
#endif
-#if defined(__linux__)
-#include <sys/uio.h>
-#endif
-
#include <atomic>
#include <iostream>
#include <limits>
@@ -255,20 +251,22 @@
int level = kLogSeverityToKernelLogLevel[severity];
- // The kernel's printk buffer is only 1024 bytes.
- // TODO: should we automatically break up long lines into multiple lines?
- // Or we could log but with something like "..." at the end?
- char buf[1024] __attribute__((__uninitialized__));
+ // The kernel's printk buffer is only |1024 - PREFIX_MAX| bytes, where
+ // PREFIX_MAX could be 48 or 32.
+ // Reference: kernel/printk/printk.c
+ static constexpr int LOG_LINE_MAX = 1024 - 48;
+ char buf[LOG_LINE_MAX] __attribute__((__uninitialized__));
size_t size = snprintf(buf, sizeof(buf), "<%d>%s: %.*s\n", level, tag, length, msg);
- if (size > sizeof(buf)) {
- size = snprintf(buf, sizeof(buf), "<%d>%s: %zu-byte message too long for printk\n",
- level, tag, size);
- }
+ TEMP_FAILURE_RETRY(write(klog_fd, buf, std::min(size, sizeof(buf))));
- iovec iov[1];
- iov[0].iov_base = buf;
- iov[0].iov_len = size;
- TEMP_FAILURE_RETRY(writev(klog_fd, iov, 1));
+ if (size > sizeof(buf)) {
+ size_t truncated = size - sizeof(buf);
+ size = snprintf(
+ buf, sizeof(buf),
+ "<%d>%s: **previous message missing %zu bytes** %zu-byte message too long for printk\n",
+ level, tag, truncated, size);
+ TEMP_FAILURE_RETRY(write(klog_fd, buf, std::min(size, sizeof(buf))));
+ }
}
void KernelLogger(android::base::LogId, android::base::LogSeverity severity, const char* tag,