From 9b553b3ddfdde52ba80aacd8f32bcb27569b5cbc Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Thu, 3 Sep 2020 11:11:31 +0300 Subject: glusterfsd, libglusterfs, rpc: prefer libglusterfs time API Use timespec_now_realtime() rather than clock_gettime(). Change-Id: I8fa00b7c0f7b388305c7d19574be3b409db68558 Signed-off-by: Dmitry Antipov Updates: #1002 --- glusterfsd/src/gf_attach.c | 4 ++-- libglusterfs/src/event.c | 3 ++- rpc/rpc-lib/src/rpc-clnt-ping.c | 2 +- rpc/rpc-lib/src/rpc-clnt.c | 5 ++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/glusterfsd/src/gf_attach.c b/glusterfsd/src/gf_attach.c index c54b4f9b516..c553b0b1f61 100644 --- a/glusterfsd/src/gf_attach.c +++ b/glusterfsd/src/gf_attach.c @@ -99,7 +99,7 @@ send_brick_req(xlator_t *this, struct rpc_clnt *rpc, char *path, int op) iov.iov_len = ret; /* Wait for connection */ - clock_gettime(CLOCK_REALTIME, &ts); + timespec_now_realtime(&ts); ts.tv_sec += CONNECT_TIMEOUT; pthread_mutex_lock(&rpc->conn.lock); { @@ -124,7 +124,7 @@ send_brick_req(xlator_t *this, struct rpc_clnt *rpc, char *path, int op) 0, iobref, frame, NULL, 0, NULL, 0, NULL); if (!ret) { /* OK, wait for callback */ - clock_gettime(CLOCK_REALTIME, &ts); + timespec_now_realtime(&ts); ts.tv_sec += REPLY_TIMEOUT; pthread_mutex_lock(&mutex); { diff --git a/libglusterfs/src/event.c b/libglusterfs/src/event.c index 235128b6044..402c253ca25 100644 --- a/libglusterfs/src/event.c +++ b/libglusterfs/src/event.c @@ -17,6 +17,7 @@ #include #include "glusterfs/gf-event.h" +#include "glusterfs/timespec.h" #include "glusterfs/common-utils.h" #include "glusterfs/libglusterfs-messages.h" #include "glusterfs/syscall.h" @@ -266,7 +267,7 @@ gf_event_dispatch_destroy(struct event_pool *event_pool) if (sys_write(fd[1], "dummy", 6) == -1) { break; } - clock_gettime(CLOCK_REALTIME, &sleep_till); + timespec_now_realtime(&sleep_till); sleep_till.tv_sec += 1; ret = pthread_cond_timedwait(&event_pool->cond, &event_pool->mutex, &sleep_till); diff --git a/rpc/rpc-lib/src/rpc-clnt-ping.c b/rpc/rpc-lib/src/rpc-clnt-ping.c index 2298ef6394f..31f17841bea 100644 --- a/rpc/rpc-lib/src/rpc-clnt-ping.c +++ b/rpc/rpc-lib/src/rpc-clnt-ping.c @@ -122,7 +122,7 @@ rpc_clnt_ping_timer_expired(void *rpc_ptr) goto out; } - clock_gettime(CLOCK_REALTIME, ¤t); + timespec_now_realtime(¤t); pthread_mutex_lock(&conn->lock); { unref = rpc_clnt_remove_ping_timer_locked(rpc); diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c index 2b0ec295525..517037c4a5d 100644 --- a/rpc/rpc-lib/src/rpc-clnt.c +++ b/rpc/rpc-lib/src/rpc-clnt.c @@ -919,7 +919,7 @@ rpc_clnt_notify(rpc_transport_t *trans, void *mydata, } case RPC_TRANSPORT_MSG_RECEIVED: { - clock_gettime(CLOCK_REALTIME, &conn->last_received); + timespec_now_realtime(&conn->last_received); pollin = data; if (pollin->is_reply) @@ -933,8 +933,7 @@ rpc_clnt_notify(rpc_transport_t *trans, void *mydata, } case RPC_TRANSPORT_MSG_SENT: { - clock_gettime(CLOCK_REALTIME, &conn->last_sent); - + timespec_now_realtime(&conn->last_sent); ret = 0; break; } -- cgit