Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9478eaa5 authored by Wei Wang's avatar Wei Wang Committed by android-build-merger
Browse files

Merge "init: add log to time spent in waiting for file" am: 7f16cad8 am: 78f06df7

am: 9d4dc02f

Change-Id: Iaca5c0efc5fcd9ba9810846f3862faf610599337
parents 589523b7 9d4dc02f
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -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;
}