summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/src/glfs.c2
-rw-r--r--libglusterfs/src/common-utils.c18
-rw-r--r--libglusterfs/src/glusterfs/common-utils.h6
-rw-r--r--libglusterfs/src/libglusterfs.sym1
-rw-r--r--libglusterfs/src/throttle-tbf.c2
-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
8 files changed, 31 insertions, 6 deletions
diff --git a/api/src/glfs.c b/api/src/glfs.c
index 0771e07..bdc2a07 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -1268,7 +1268,7 @@ pub_glfs_fini(struct glfs *fs)
}
}
pthread_mutex_unlock(&fs->mutex);
- usleep(100000);
+ gf_nanosleep(100000 * GF_US_IN_NS);
}
/* leaked frames may exist, we ignore */
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 8e2ffa3..132e63e 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -5421,3 +5421,21 @@ gf_d_type_from_ia_type(ia_type_t type)
return DT_UNKNOWN;
}
}
+
+int
+gf_nanosleep(uint64_t nsec)
+{
+ struct timespec req;
+ struct timespec rem;
+ int ret = -1;
+
+ req.tv_sec = nsec / GF_SEC_IN_NS;
+ req.tv_nsec = nsec % GF_SEC_IN_NS;
+
+ do {
+ ret = nanosleep(&req, &rem);
+ req = rem;
+ } while (ret == -1 && errno == EINTR);
+
+ return ret;
+}
diff --git a/libglusterfs/src/glusterfs/common-utils.h b/libglusterfs/src/glusterfs/common-utils.h
index 4132849..b184031 100644
--- a/libglusterfs/src/glusterfs/common-utils.h
+++ b/libglusterfs/src/glusterfs/common-utils.h
@@ -115,6 +115,9 @@ trap(void);
#define GF_HOUR_IN_SECONDS (60 * 60)
#define GF_DAY_IN_SECONDS (24 * 60 * 60)
#define GF_WEEK_IN_SECONDS (7 * 24 * 60 * 60)
+#define GF_SEC_IN_NS 1000000000
+#define GF_MS_IN_NS 1000000
+#define GF_US_IN_NS 1000
/* Default timeout for both barrier and changelog translator */
#define BARRIER_TIMEOUT "120"
@@ -1165,4 +1168,7 @@ find_xlator_option_in_cmd_args_t(const char *option_name, cmd_args_t *args);
int
gf_d_type_from_ia_type(ia_type_t type);
+int
+gf_nanosleep(uint64_t nsec);
+
#endif /* _COMMON_UTILS_H */
diff --git a/libglusterfs/src/libglusterfs.sym b/libglusterfs/src/libglusterfs.sym
index 188cda2..0e24630 100644
--- a/libglusterfs/src/libglusterfs.sym
+++ b/libglusterfs/src/libglusterfs.sym
@@ -1166,3 +1166,4 @@ glusterfs_mux_volfile_reconfigure
glusterfs_process_svc_detach
mgmt_is_multiplexed_daemon
xlator_is_cleanup_starting
+gf_nanosleep
diff --git a/libglusterfs/src/throttle-tbf.c b/libglusterfs/src/throttle-tbf.c
index 81efebd..e11ca4f 100644
--- a/libglusterfs/src/throttle-tbf.c
+++ b/libglusterfs/src/throttle-tbf.c
@@ -99,7 +99,7 @@ tbf_tokengenerator(void *arg)
token_gen_interval = bucket->token_gen_interval;
while (1) {
- usleep(token_gen_interval);
+ gf_nanosleep(token_gen_interval * GF_US_IN_NS);
LOCK(&bucket->lock);
{
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);