From e0aaaccefdfda345b981b86dea23b2ffa52e9377 Mon Sep 17 00:00:00 2001 From: Zhou Zhengping Date: Sun, 7 May 2017 17:29:26 +0800 Subject: rpc: use GF_ATOMIC_INC to generate rpc_clnt's callid Change-Id: I57ad970411db1ccd3d2c56c504c7da9cc221051f BUG: 1448692 Signed-off-by: Zhou Zhengping Reviewed-on: https://review.gluster.org/17198 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Niels de Vos CentOS-regression: Gluster Build System Reviewed-by: Raghavendra G --- rpc/rpc-lib/src/rpc-clnt.c | 18 ++---------------- rpc/rpc-lib/src/rpc-clnt.h | 2 +- 2 files changed, 3 insertions(+), 17 deletions(-) (limited to 'rpc/rpc-lib') diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c index d7a06c33d32..ef8f764b62f 100644 --- a/rpc/rpc-lib/src/rpc-clnt.c +++ b/rpc/rpc-lib/src/rpc-clnt.c @@ -24,21 +24,6 @@ void rpc_clnt_reply_deinit (struct rpc_req *req, struct mem_pool *pool); -uint64_t -rpc_clnt_new_callid (struct rpc_clnt *clnt) -{ - uint64_t callid = 0; - - pthread_mutex_lock (&clnt->lock); - { - callid = ++clnt->xid; - } - pthread_mutex_unlock (&clnt->lock); - - return callid; -} - - struct saved_frame * __saved_frames_get_timedout (struct saved_frames *frames, uint32_t timeout, struct timeval *current) @@ -1144,6 +1129,7 @@ rpc_clnt_new (dict_t *options, xlator_t *owner, char *name, pthread_mutex_init (&rpc->lock, NULL); rpc->ctx = ctx; rpc->owner = owner; + GF_ATOMIC_INIT (rpc->xid, 1); if (!reqpool_size) reqpool_size = RPC_CLNT_DEFAULT_REQUEST_COUNT; @@ -1636,7 +1622,7 @@ rpc_clnt_submit (struct rpc_clnt *rpc, rpc_clnt_prog_t *prog, new_iobref = 1; } - callid = rpc_clnt_new_callid (rpc); + callid = GF_ATOMIC_INC (rpc->xid); rpcreq->prog = prog; rpcreq->procnum = procnum; diff --git a/rpc/rpc-lib/src/rpc-clnt.h b/rpc/rpc-lib/src/rpc-clnt.h index e5e493cd79e..952ecbce1a1 100644 --- a/rpc/rpc-lib/src/rpc-clnt.h +++ b/rpc/rpc-lib/src/rpc-clnt.h @@ -176,7 +176,7 @@ typedef struct rpc_clnt { rpc_clnt_notify_t notifyfn; rpc_clnt_connection_t conn; void *mydata; - uint64_t xid; + gf_atomic_t xid; /* list of cb programs registered with rpc-clnt */ struct list_head programs; -- cgit