Merge "init: add log to time spent in waiting for file" am: 7f16cad877
am: 78f06df7b1
Change-Id: I0833d0007980d65a95fb7c96c00a0e16718b7fda
This commit is contained in:
commit
9d4dc02f95
1 changed files with 7 additions and 4 deletions
|
|
@ -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) {
|
int wait_for_file(const char* filename, std::chrono::nanoseconds timeout) {
|
||||||
boot_clock::time_point timeout_time = boot_clock::now() + timeout;
|
android::base::Timer t;
|
||||||
while (boot_clock::now() < timeout_time) {
|
while (t.duration() < timeout) {
|
||||||
struct stat sb;
|
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);
|
std::this_thread::sleep_for(10ms);
|
||||||
}
|
}
|
||||||
|
LOG(WARNING) << "wait for '" << filename << "' timed out and took " << t;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue