From 3c1efa0c92445638bbfa57c2e868c79f7d987fc3 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Thu, 20 Jun 2019 15:50:01 -0700 Subject: Replace usleep() with nanosleep() As usleep has been obsoleted, changed all invocations of usleep to nanosleep. From man 3 usleep: "4.3BSD, POSIX.1-2001. POSIX.1-2001 declares this function obsolete; use nanosleep(2) instead. POSIX.1-2008 removes the specification of usleep()." Added a helper function gf_nanosleep() to have a single place for handling edge cases that might arise from the conversion of usleep to nanosleep and allow the sleep to resume with right remaining value upon being interrupted. Fixes: bz#1721686 Change-Id: Ia39ab82c9e0f4669d2c00d4cdf25e38d94ef9f62 Signed-off-by: Vijay Bellur --- xlators/debug/delay-gen/src/delay-gen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xlators/debug') diff --git a/xlators/debug/delay-gen/src/delay-gen.c b/xlators/debug/delay-gen/src/delay-gen.c index 76efacb3044..4698f1fd785 100644 --- a/xlators/debug/delay-gen/src/delay-gen.c +++ b/xlators/debug/delay-gen/src/delay-gen.c @@ -27,7 +27,7 @@ delay_gen(xlator_t *this, int fop) return 0; if ((rand() % DELAY_GRANULARITY) < dg->delay_ppm) - usleep(dg->delay_duration); + gf_nanosleep(dg->delay_duration * GF_US_IN_NS); return 0; } -- cgit