summaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorThierry Strudel <tstrudel@google.com>2015-05-22 15:56:14 -0700
committerThierry Strudel <tstrudel@google.com>2015-05-22 16:03:12 -0700
commit91cf41cf43847930a8e55b3789d4943a8e22f73a (patch)
tree7bfeda8ca0017760e4b9014a54b2572bbd6269ea /init
parenta552f07f7e9aa75dae814ddff94b33b4506794ab (diff)
downloadsystem_core-91cf41cf43847930a8e55b3789d4943a8e22f73a.zip
system_core-91cf41cf43847930a8e55b3789d4943a8e22f73a.tar.gz
system_core-91cf41cf43847930a8e55b3789d4943a8e22f73a.tar.bz2
init: wait_for_file use smaller time resolution
As 1s timeout can be requested, using second resolution time to check for timeout prevent from being accurate on the actual time we wait. Use available gettime_ns instead. Bug: 21374269 Change-Id: I8be1b69e02beacc7196427f97855e036addf54d1 Signed-off-by: Thierry Strudel <tstrudel@google.com>
Diffstat (limited to 'init')
-rw-r--r--init/util.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/init/util.cpp b/init/util.cpp
index df4c25f..b3947f7 100644
--- a/init/util.cpp
+++ b/init/util.cpp
@@ -366,10 +366,10 @@ void remove_link(const char *oldpath, const char *newpath)
int wait_for_file(const char *filename, int timeout)
{
struct stat info;
- time_t timeout_time = gettime() + timeout;
+ uint64_t timeout_time_ns = gettime_ns() + timeout * UINT64_C(1000000000);
int ret = -1;
- while (gettime() < timeout_time && ((ret = stat(filename, &info)) < 0))
+ while (gettime_ns() < timeout_time_ns && ((ret = stat(filename, &info)) < 0))
usleep(10000);
return ret;