diff options
author | Jin Qian <jinqian@google.com> | 2017-01-26 11:20:26 -0800 |
---|---|---|
committer | Jin Qian <jinqian@google.com> | 2017-01-26 11:20:26 -0800 |
commit | f42d7c833c4e719a5a5e2a5661ef21abf927a885 (patch) | |
tree | 89a7295f76ac0a100bd2536129a43c4a73913e88 /storaged/storaged.cpp | |
parent | f4a7b33dfe6dbdada832423ba54dd47b8766b5d9 (diff) | |
download | core-f42d7c833c4e719a5a5e2a5661ef21abf927a885.tar.gz core-f42d7c833c4e719a5a5e2a5661ef21abf927a885.tar.bz2 core-f42d7c833c4e719a5a5e2a5661ef21abf927a885.zip |
storaged: fix check_time logic
Skips event time check if failed to get start time.
Use ratelimited logging when gettime fails.
Test: adb shell setprop ro.storaged.event.perf_check 10000
Bug: 34630954
Bug: 34198239
Change-Id: I168ef3b4e4ed27257ec76373219c6214a7b7b2ed
Diffstat (limited to 'storaged/storaged.cpp')
-rw-r--r-- | storaged/storaged.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/storaged/storaged.cpp b/storaged/storaged.cpp index d3fa2b97d..73df6d0d4 100644 --- a/storaged/storaged.cpp +++ b/storaged/storaged.cpp @@ -22,6 +22,7 @@ #include <android-base/logging.h> #include <cutils/properties.h> +#include <log/log.h> #include <storaged.h> #include <storaged_utils.h> @@ -217,14 +218,20 @@ void storaged_t::event_checked(void) { if (mConfig.event_time_check_usec && clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start_ts) < 0) { check_time = false; - PLOG_TO(SYSTEM, ERROR) << "clock_gettime() failed"; + static time_t state_a; + IF_ALOG_RATELIMIT_LOCAL(300, &state_a) { + PLOG_TO(SYSTEM, ERROR) << "clock_gettime() failed"; + } } event(); - if (mConfig.event_time_check_usec) { + if (mConfig.event_time_check_usec && check_time) { if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end_ts) < 0) { - PLOG_TO(SYSTEM, ERROR) << "clock_gettime() failed"; + static time_t state_b; + IF_ALOG_RATELIMIT_LOCAL(300, &state_b) { + PLOG_TO(SYSTEM, ERROR) << "clock_gettime() failed"; + } return; } int64_t cost = (end_ts.tv_sec - start_ts.tv_sec) * SEC_TO_USEC + |