diff options
Diffstat (limited to 'xlators/features')
-rw-r--r-- | xlators/features/changelog/src/changelog-ev-handle.h | 22 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-rpc.c | 2 |
2 files changed, 9 insertions, 15 deletions
diff --git a/xlators/features/changelog/src/changelog-ev-handle.h b/xlators/features/changelog/src/changelog-ev-handle.h index eef0492a9ee..e89af8793a8 100644 --- a/xlators/features/changelog/src/changelog-ev-handle.h +++ b/xlators/features/changelog/src/changelog-ev-handle.h @@ -24,7 +24,7 @@ typedef struct changelog_rpc_clnt { gf_lock_t lock; - unsigned long ref; + gf_atomic_t ref; gf_boolean_t disconnected; unsigned int filter; @@ -43,11 +43,7 @@ typedef struct changelog_rpc_clnt { static inline void changelog_rpc_clnt_ref (changelog_rpc_clnt_t *crpc) { - LOCK (&crpc->lock); - { - ++crpc->ref; - } - UNLOCK (&crpc->lock); + GF_ATOMIC_INC (crpc->ref); } static inline void @@ -66,16 +62,14 @@ static inline void changelog_rpc_clnt_unref (changelog_rpc_clnt_t *crpc) { gf_boolean_t gone = _gf_false; + uint64_t ref = 0; + + ref = GF_ATOMIC_DEC (crpc->ref); - LOCK (&crpc->lock); - { - if (!(--crpc->ref) - && changelog_rpc_clnt_is_disconnected (crpc)) { - list_del (&crpc->list); - gone = _gf_true; - } + if (!ref && changelog_rpc_clnt_is_disconnected (crpc)) { + list_del (&crpc->list); + gone = _gf_true; } - UNLOCK (&crpc->lock); if (gone) crpc->cleanup (crpc); diff --git a/xlators/features/changelog/src/changelog-rpc.c b/xlators/features/changelog/src/changelog-rpc.c index 5524e433cbb..72b5cdbc7cb 100644 --- a/xlators/features/changelog/src/changelog-rpc.c +++ b/xlators/features/changelog/src/changelog-rpc.c @@ -211,7 +211,7 @@ changelog_rpc_clnt_init (xlator_t *this, /* Take a ref, the last unref will be on RPC_CLNT_DESTROY * which comes as a result of last rpc_clnt_unref. */ - crpc->ref = 1; + GF_ATOMIC_INIT (crpc->ref, 1); changelog_set_disconnect_flag (crpc, _gf_false); crpc->filter = rpc_req->filter; |