diff options
author | Alan Stokes <alanstokes@google.com> | 2017-08-01 16:43:02 +0100 |
---|---|---|
committer | Alan Stokes <alanstokes@google.com> | 2017-08-25 18:21:36 +0100 |
commit | e0515d6dba5fa50e6319ab65b94232ed88bebd72 (patch) | |
tree | 63f54512f400fbe51adb5b4137209bcda12596db /liblog/logd_reader.c | |
parent | 3094de968443c60345f63318f14a5d919df762d5 (diff) | |
download | core-e0515d6dba5fa50e6319ab65b94232ed88bebd72.tar.gz core-e0515d6dba5fa50e6319ab65b94232ed88bebd72.tar.bz2 core-e0515d6dba5fa50e6319ab65b94232ed88bebd72.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.
(cherry picked from commit 64acdf77d6f89a72be9192b35e0fc34242c23e34)
Change-Id: Ic2ec131a3aee293ee865c46e62566ddd82ec2507
Diffstat (limited to 'liblog/logd_reader.c')
-rw-r--r-- | liblog/logd_reader.c | 14 |
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, memset(log_msg, 0, sizeof(*log_msg)); + unsigned int new_alarm = 0; if (logger_list->mode & ANDROID_LOG_NONBLOCK) { + if ((logger_list->mode & ANDROID_LOG_WRAP) && + (logger_list->start.tv_sec || logger_list->start.tv_nsec)) { + /* b/64143705 */ + new_alarm = (ANDROID_LOG_WRAP_DEFAULT_TIMEOUT * 11) / 10 + 10; + logger_list->mode &= ~ANDROID_LOG_WRAP; + } else { + new_alarm = 30; + } + memset(&ignore, 0, sizeof(ignore)); ignore.sa_handler = caught_signal; sigemptyset(&ignore.sa_mask); /* particularily useful if tombstone is reporting for logd */ sigaction(SIGALRM, &ignore, &old_sigaction); - old_alarm = alarm(30); + old_alarm = alarm(new_alarm); } /* NOTE: SOCK_SEQPACKET guarantees we read exactly one full entry */ ret = recv(ret, log_msg, LOGGER_ENTRY_MAX_LEN, 0); e = errno; - if (logger_list->mode & ANDROID_LOG_NONBLOCK) { + if (new_alarm) { if ((ret == 0) || (e == EINTR)) { e = EAGAIN; ret = -1; |