diff options
author | Karel Zak | 2014-11-18 14:35:21 +0100 |
---|---|---|
committer | Karel Zak | 2014-11-18 14:35:21 +0100 |
commit | 700031ade7cbcdcecf1205f98f50ed0da57c7493 (patch) | |
tree | 4ff850a1015129cb448577dd1c4d9ca461cbb041 /libmount/src | |
parent | uuidd: Fixed a typo in daemon logging message (diff) | |
download | kernel-qcow2-util-linux-700031ade7cbcdcecf1205f98f50ed0da57c7493.tar.gz kernel-qcow2-util-linux-700031ade7cbcdcecf1205f98f50ed0da57c7493.tar.xz kernel-qcow2-util-linux-700031ade7cbcdcecf1205f98f50ed0da57c7493.zip |
misc: use monotonic time rater than gettimeofday
Based on patch Alexander Samilovskih <alexsamilovskih@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src')
-rw-r--r-- | libmount/src/lock.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libmount/src/lock.c b/libmount/src/lock.c index 8667db999..0a07e9b03 100644 --- a/libmount/src/lock.c +++ b/libmount/src/lock.c @@ -25,6 +25,7 @@ #include "closestream.h" #include "pathnames.h" #include "mountP.h" +#include "timeutils.h" /* * lock handler @@ -258,7 +259,7 @@ static int mnt_wait_mtab_lock(struct libmnt_lock *ml, struct flock *fl, time_t m struct sigaction sa, osa; int ret = 0; - gettimeofday(&now, NULL); + gettime_monotonic(&now); if (now.tv_sec >= maxtime) return 1; /* timeout */ @@ -408,7 +409,7 @@ static int lock_mtab(struct libmnt_lock *ml) } close(i); - gettimeofday(&maxtime, NULL); + gettime_monotonic(&maxtime); maxtime.tv_sec += MOUNTLOCK_MAXTIME; waittime.tv_sec = 0; @@ -434,7 +435,7 @@ static int lock_mtab(struct libmnt_lock *ml) if (ml->lockfile_fd < 0) { /* Strange... Maybe the file was just deleted? */ int errsv = errno; - gettimeofday(&now, NULL); + gettime_monotonic(&now); if (errsv == ENOENT && now.tv_sec < maxtime.tv_sec) { ml->locked = 0; continue; @@ -646,7 +647,7 @@ int test_lock(struct libmnt_test *ts, int argc, char *argv[]) /* start the test in exactly defined time */ if (synctime) { - gettimeofday(&tv, NULL); + gettime_monotonic(&tv); if (synctime && synctime - tv.tv_sec > 1) { usecs = ((synctime - tv.tv_sec) * 1000000UL) - (1000000UL - tv.tv_usec); |