summaryrefslogtreecommitdiffstats
path: root/liblog
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2014-01-09 07:45:30 -0800
committerMark Salyzyn <salyzyn@google.com>2014-01-27 15:14:18 -0800
commitd0a83fddf18de1a567692a0eeb43228601c83fcf (patch)
tree5fac4fc0570231eab9eb17b44e4c9c0e0264a3bd /liblog
parent11aa6ee98c5cc67e149acb7c634f6c2546678c00 (diff)
downloadsystem_core-d0a83fddf18de1a567692a0eeb43228601c83fcf.zip
system_core-d0a83fddf18de1a567692a0eeb43228601c83fcf.tar.gz
system_core-d0a83fddf18de1a567692a0eeb43228601c83fcf.tar.bz2
liblog: high CPU usage from logcat
BUG: 12457855 - log_read.c poll timeout should be -1 instead of 0 when idling (cherry picked from commit 080bbfab94ce91e4845860d5253eea6d869bbc18) Change-Id: I9082a15fae0fbf999c0ed516950a49d65a279298
Diffstat (limited to 'liblog')
-rw-r--r--liblog/log_read.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/liblog/log_read.c b/liblog/log_read.c
index 11464ce..379105f 100644
--- a/liblog/log_read.c
+++ b/liblog/log_read.c
@@ -1,5 +1,5 @@
/*
-** Copyright 2013, The Android Open Source Project
+** Copyright 2013-2014, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
@@ -31,7 +31,9 @@ typedef char bool;
#define LOG_FILE_DIR "/dev/log/"
-#define LOG_TIMEOUT_MS 5
+/* timeout in milliseconds */
+#define LOG_TIMEOUT_FLUSH 5
+#define LOG_TIMEOUT_NEVER -1
#define logger_for_each(logger, logger_list) \
for (logger = node_to_item((logger_list)->node.next, struct logger, node); \
@@ -291,7 +293,7 @@ struct logger *android_logger_open(struct logger_list *logger_list,
list_init(&logger->log_list);
list_add_tail(&logger_list->node, &logger->node);
logger->top = logger_list;
- logger_list->timeout_ms = LOG_TIMEOUT_MS;
+ logger_list->timeout_ms = LOG_TIMEOUT_FLUSH;
goto ok;
err_name:
@@ -494,14 +496,14 @@ int android_logger_list_read(struct logger_list *logger_list,
} else if (logger_list->mode & O_NDELAY) {
error = EAGAIN;
} else {
- logger_list->timeout_ms = 0;
+ logger_list->timeout_ms = LOG_TIMEOUT_NEVER;
}
logger_list->flush = true;
goto try_flush;
}
- logger_list->timeout_ms = LOG_TIMEOUT_MS;
+ logger_list->timeout_ms = LOG_TIMEOUT_FLUSH;
/* Anti starvation */
if (!logger_list->flush