summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorVijay Bellur <vbellur@redhat.com>2019-06-20 15:50:01 -0700
committerXavi Hernandez <xhernandez@redhat.com>2019-07-11 10:37:52 +0000
commit3c1efa0c92445638bbfa57c2e868c79f7d987fc3 (patch)
tree3cc28f420d5aebe771de4985fc669dd99e8a42fa /xlators
parentb82743a5822626e83b233956803421fda9b1c3f9 (diff)
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 <vbellur@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/debug/delay-gen/src/delay-gen.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-geo-rep.c4
-rw-r--r--xlators/storage/posix/src/posix-helpers.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/xlators/debug/delay-gen/src/delay-gen.c b/xlators/debug/delay-gen/src/delay-gen.c
index 76efacb..4698f1f 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;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
index 3bbc7dc..c98cf48 100644
--- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
+++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
@@ -4167,10 +4167,10 @@ stop_gsync(char *master, char *slave, char **msg, char *conf_path,
* still be alive, give some more time
* before SIGKILL (hack)
*/
- usleep(50000);
+ gf_nanosleep(50000 * GF_US_IN_NS);
break;
}
- usleep(50000);
+ gf_nanosleep(50000 * GF_US_IN_NS);
}
kill(-pid, SIGKILL);
sys_unlink(pidfile);
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index b3e55e4..bb20a93 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -2473,7 +2473,7 @@ posix_fsyncer(void *d)
count = posix_fsyncer_pick(this, &list);
- usleep(priv->batch_fsync_delay_usec);
+ gf_nanosleep(priv->batch_fsync_delay_usec * GF_US_IN_NS);
gf_msg_debug(this->name, 0, "picked %d fsyncs", count);