summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Stokes2017-08-01 10:43:02 -0500
committerAlan Stokes2017-08-25 05:40:49 -0500
commit64acdf77d6f89a72be9192b35e0fc34242c23e34 (patch)
treed81aec0a47fa9caaceb0aa5c61553b411102af3a /liblog/logd_reader.c
parent2732a7e0232d77efbf19d7053f5e5d5d39719910 (diff)
downloadplatform-system-core-64acdf77d6f89a72be9192b35e0fc34242c23e34.tar.gz
platform-system-core-64acdf77d6f89a72be9192b35e0fc34242c23e34.tar.xz
platform-system-core-64acdf77d6f89a72be9192b35e0fc34242c23e34.zip
Reading from logd in WRAP mode is expected to take a long time,
don't abort it after 30s. Adds a new CTS test to verify the behaviour. Bug: 64143705 Test: New and existing CTS tests pass. Manual testing with logcat. Change-Id: Ia67175701ed8c462083e14e26123ce8ddcb226bc
Diffstat (limited to 'liblog/logd_reader.c')
-rw-r--r--liblog/logd_reader.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/liblog/logd_reader.c b/liblog/logd_reader.c
index 600f4bb0b..603ba2469 100644
--- a/liblog/logd_reader.c
+++ b/liblog/logd_reader.c
@@ -590,20 +590,30 @@ static int logdRead(struct android_log_logger_list* logger_list,
590 590
591 memset(log_msg, 0, sizeof(*log_msg)); 591 memset(log_msg, 0, sizeof(*log_msg));
592 592
593 unsigned int new_alarm = 0;
593 if (logger_list->mode & ANDROID_LOG_NONBLOCK) { 594 if (logger_list->mode & ANDROID_LOG_NONBLOCK) {
595 if ((logger_list->mode & ANDROID_LOG_WRAP) &&
596 (logger_list->start.tv_sec || logger_list->start.tv_nsec)) {
597 /* b/64143705 */
598 new_alarm = (ANDROID_LOG_WRAP_DEFAULT_TIMEOUT * 11) / 10 + 10;
599 logger_list->mode &= ~ANDROID_LOG_WRAP;
600 } else {
601 new_alarm = 30;
602 }
603
594 memset(&ignore, 0, sizeof(ignore)); 604 memset(&ignore, 0, sizeof(ignore));
595 ignore.sa_handler = caught_signal; 605 ignore.sa_handler = caught_signal;
596 sigemptyset(&ignore.sa_mask); 606 sigemptyset(&ignore.sa_mask);
597 /* particularily useful if tombstone is reporting for logd */ 607 /* particularily useful if tombstone is reporting for logd */
598 sigaction(SIGALRM, &ignore, &old_sigaction); 608 sigaction(SIGALRM, &ignore, &old_sigaction);
599 old_alarm = alarm(30); 609 old_alarm = alarm(new_alarm);
600 } 610 }
601 611
602 /* NOTE: SOCK_SEQPACKET guarantees we read exactly one full entry */ 612 /* NOTE: SOCK_SEQPACKET guarantees we read exactly one full entry */
603 ret = recv(ret, log_msg, LOGGER_ENTRY_MAX_LEN, 0); 613 ret = recv(ret, log_msg, LOGGER_ENTRY_MAX_LEN, 0);
604 e = errno; 614 e = errno;
605 615
606 if (logger_list->mode & ANDROID_LOG_NONBLOCK) { 616 if (new_alarm) {
607 if ((ret == 0) || (e == EINTR)) { 617 if ((ret == 0) || (e == EINTR)) {
608 e = EAGAIN; 618 e = EAGAIN;
609 ret = -1; 619 ret = -1;