diff options
author | Karel Zak | 2014-01-24 13:04:14 +0100 |
---|---|---|
committer | Karel Zak | 2014-01-24 13:04:14 +0100 |
commit | a5bd7939961aaa6e39f3b298e556063cfd97d75a (patch) | |
tree | c7b5425996072f268f5cbb6c5496a4a2a95a5256 /libmount/src/lock.c | |
parent | flock: Change the 'exit status' man page section to make more sense (diff) | |
download | kernel-qcow2-util-linux-a5bd7939961aaa6e39f3b298e556063cfd97d75a.tar.gz kernel-qcow2-util-linux-a5bd7939961aaa6e39f3b298e556063cfd97d75a.tar.xz kernel-qcow2-util-linux-a5bd7939961aaa6e39f3b298e556063cfd97d75a.zip |
include/c.h: prefer nanosleep() over usleep()
Let's use nanosleep() although if usleep() exists. The nanosleep
function does no interact with signals and other timers.
The patch introduces xusleep() as replacement to libc (or our fallback)
usleep(). Yes, we don't want to use struct timespec + nanosleep()
everywhere in code as nano-time resolution is useless for us.
The patch also enlarges delays in some busy wait loops. It seems
enough to try read/write 4x per second.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/lock.c')
-rw-r--r-- | libmount/src/lock.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libmount/src/lock.c b/libmount/src/lock.c index d9b6f5939..734757d81 100644 --- a/libmount/src/lock.c +++ b/libmount/src/lock.c @@ -650,7 +650,7 @@ int test_lock(struct libmnt_test *ts, int argc, char *argv[]) if (synctime && synctime - tv.tv_sec > 1) { usecs = ((synctime - tv.tv_sec) * 1000000UL) - (1000000UL - tv.tv_usec); - usleep(usecs); + xusleep(usecs); } } @@ -676,7 +676,7 @@ int test_lock(struct libmnt_test *ts, int argc, char *argv[]) * concurrent processes happy. */ if (synctime) - usleep(25000); + xusleep(25000); } return 0; |