summaryrefslogtreecommitdiffstats
path: root/init/util.cpp
diff options
context:
space:
mode:
authorWei Wang <wvw@google.com>2017-08-22 12:07:37 -0700
committerWei Wang <wvw@google.com>2017-08-22 14:09:11 -0700
commit4cea121872d9b0d18d4d57103de89934a82b554a (patch)
tree55614a938e83c51387f7aab30c030c3d6415ec60 /init/util.cpp
parent46244a6497ac6b0b1a589e40a67d0f99f462ba1e (diff)
downloadsystem_core-4cea121872d9b0d18d4d57103de89934a82b554a.tar.gz
system_core-4cea121872d9b0d18d4d57103de89934a82b554a.tar.bz2
system_core-4cea121872d9b0d18d4d57103de89934a82b554a.zip
init: add log to time spent in waiting for file
Bug: 64925999 Test: boot and take log Change-Id: I7d37906708b5a4a195fb1ba1113641656d419e62
Diffstat (limited to 'init/util.cpp')
-rw-r--r--init/util.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/init/util.cpp b/init/util.cpp
index 9112c3fd3..a19a6f3c3 100644
--- a/init/util.cpp
+++ b/init/util.cpp
@@ -206,13 +206,16 @@ bool mkdir_recursive(const std::string& path, mode_t mode) {
}
int wait_for_file(const char* filename, std::chrono::nanoseconds timeout) {
- boot_clock::time_point timeout_time = boot_clock::now() + timeout;
- while (boot_clock::now() < timeout_time) {
+ android::base::Timer t;
+ while (t.duration() < timeout) {
struct stat sb;
- if (stat(filename, &sb) != -1) return 0;
-
+ if (stat(filename, &sb) != -1) {
+ LOG(INFO) << "wait for '" << filename << "' took " << t;
+ return 0;
+ }
std::this_thread::sleep_for(10ms);
}
+ LOG(WARNING) << "wait for '" << filename << "' timed out and took " << t;
return -1;
}