diff options
author | Zhou Zhengping <johnzzpcrystal@gmail.com> | 2017-05-07 17:29:26 +0800 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2017-05-08 04:08:29 +0000 |
commit | e0aaaccefdfda345b981b86dea23b2ffa52e9377 (patch) | |
tree | 0627e9fee1981f743433d1401a653f58fa545b55 /rpc/rpc-lib | |
parent | 2502162502009d4be75e67e49d71f3f38aaa7595 (diff) |
rpc: use GF_ATOMIC_INC to generate rpc_clnt's callid
Change-Id: I57ad970411db1ccd3d2c56c504c7da9cc221051f
BUG: 1448692
Signed-off-by: Zhou Zhengping <johnzzpcrystal@gmail.com>
Reviewed-on: https://review.gluster.org/17198
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'rpc/rpc-lib')
-rw-r--r-- | rpc/rpc-lib/src/rpc-clnt.c | 18 | ||||
-rw-r--r-- | rpc/rpc-lib/src/rpc-clnt.h | 2 |
2 files changed, 3 insertions, 17 deletions
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; |