diff options
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/rpc-lib/src/rpc-clnt.c | 15 | ||||
-rw-r--r-- | rpc/rpc-lib/src/rpc-clnt.h | 2 | ||||
-rw-r--r-- | rpc/rpc-lib/src/rpc-transport.c | 12 | ||||
-rw-r--r-- | rpc/rpc-lib/src/rpc-transport.h | 2 |
4 files changed, 9 insertions, 22 deletions
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c index cb59408dcf6..06aed0a80ae 100644 --- a/rpc/rpc-lib/src/rpc-clnt.c +++ b/rpc/rpc-lib/src/rpc-clnt.c @@ -1740,11 +1740,8 @@ rpc_clnt_ref (struct rpc_clnt *rpc) { if (!rpc) return NULL; - pthread_mutex_lock (&rpc->lock); - { - rpc->refcount++; - } - pthread_mutex_unlock (&rpc->lock); + + GF_ATOMIC_INC (rpc->refcount); return rpc; } @@ -1806,11 +1803,9 @@ rpc_clnt_unref (struct rpc_clnt *rpc) if (!rpc) return NULL; - pthread_mutex_lock (&rpc->lock); - { - count = --rpc->refcount; - } - pthread_mutex_unlock (&rpc->lock); + + count = GF_ATOMIC_DEC (rpc->refcount); + if (!count) { rpc_clnt_trigger_destroy (rpc); return NULL; diff --git a/rpc/rpc-lib/src/rpc-clnt.h b/rpc/rpc-lib/src/rpc-clnt.h index 428ffb80650..6503ca5a573 100644 --- a/rpc/rpc-lib/src/rpc-clnt.h +++ b/rpc/rpc-lib/src/rpc-clnt.h @@ -187,7 +187,7 @@ typedef struct rpc_clnt { struct mem_pool *saved_frames_pool; glusterfs_ctx_t *ctx; - int refcount; + gf_atomic_t refcount; int auth_null; char disabled; xlator_t *owner; diff --git a/rpc/rpc-lib/src/rpc-transport.c b/rpc/rpc-lib/src/rpc-transport.c index 40b5917f9b8..40c41ab7016 100644 --- a/rpc/rpc-lib/src/rpc-transport.c +++ b/rpc/rpc-lib/src/rpc-transport.c @@ -493,11 +493,7 @@ rpc_transport_ref (rpc_transport_t *this) GF_VALIDATE_OR_GOTO("rpc_transport", this, fail); - pthread_mutex_lock (&this->lock); - { - this->refcount ++; - } - pthread_mutex_unlock (&this->lock); + GF_ATOMIC_INC (this->refcount); return_this = this; fail: @@ -513,11 +509,7 @@ rpc_transport_unref (rpc_transport_t *this) GF_VALIDATE_OR_GOTO("rpc_transport", this, fail); - pthread_mutex_lock (&this->lock); - { - refcount = --this->refcount; - } - pthread_mutex_unlock (&this->lock); + refcount = GF_ATOMIC_DEC (this->refcount); if (refcount == 0) { if (this->mydata) diff --git a/rpc/rpc-lib/src/rpc-transport.h b/rpc/rpc-lib/src/rpc-transport.h index 33f474e42c6..332efb45c25 100644 --- a/rpc/rpc-lib/src/rpc-transport.h +++ b/rpc/rpc-lib/src/rpc-transport.h @@ -184,7 +184,7 @@ struct rpc_transport { void *xl; /* Used for THIS */ void *mydata; pthread_mutex_t lock; - int32_t refcount; + gf_atomic_t refcount; int32_t outstanding_rpc_count; |