logd: wakeup wrap timeout if realtime changes drastically
--wrap flag in logcat translates directly to the mTimeout inside logd, the value set is ANDROID_LOG_WRAP_DEFAULT_TIMEOUT defined in <log/log_read.h> as 7200 or 2 hours. For a non blocking read with a selected timeout, the logger waits until either the log buffer is about to 'wrap' and prune the log entry, or at the specified timeout. Non blocking in the logger context means that when there are no more log entries, the socket is closed. clock_gettime(CLOCK_REALTIME) is UTC 1970 epoch *NIX time. Is only affected for time updates, not timezone or daylight savings time. If there is a large user initiated time change, both the log entries and the timeout mentioned above really get called into question, so we trigger a release of the logs for clarity. This is so that the log reader can handle the disruptively updated time, and can immediately check the local time if necessary. The logger has a 5 second window for entries to land in time sorted order into the logging list. This should offer the log reader some differentiation between logging order sequence for monotonically increasing time, and sequence order in the face of user initiated time adjustments that break monotonicity. This change is about major time adjustments that can cause Fear, Uncertainty or Doubt about log entries. By returning, immediate action can be taken, rather than having to comb through the logs with less details about the time disruptions in hand. The least it can do is record what we have, and restart the call with a new tail time and timeout. Test: gTest liblog-unit-tests logcat-unit-test logd-unit-tests Bug: 35373582 Change-Id: I92cac83be99d68634ffd4ebd2f3a3067cfd0e942
Loading
Please register or sign in to comment