From b3188c61d248526a070b1b18df1ea1d181b349d6 Mon Sep 17 00:00:00 2001 From: Rajesh Joseph Date: Thu, 5 Jan 2017 23:58:21 +0530 Subject: socket: GF_REF_PUT should be called outside lock GF_REF_PUT was called inside lock which can call socket_poller_mayday which inturn tries to take the same lock. This can lead to deadlock scenario. BUG: 1410701 Change-Id: Ib3b161bcfeac810bd3593dc04c10ef984f996b17 Signed-off-by: Rajesh Joseph Reviewed-on: https://review.gluster.org/16343 Reviewed-by: Raghavendra G CentOS-regression: Gluster Build System Smoke: Gluster Build System NetBSD-regression: NetBSD Build System --- rpc/rpc-transport/socket/src/socket.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c index 990571289c1..09020aa68ae 100644 --- a/rpc/rpc-transport/socket/src/socket.c +++ b/rpc/rpc-transport/socket/src/socket.c @@ -2427,7 +2427,6 @@ socket_poller (void *ctx) * conditionally */ THIS = this->xl; - GF_REF_GET (priv); if (priv->ot_state == OT_PLEASE_DIE) { gf_log (this->name, GF_LOG_DEBUG, "socket_poller is exiting " @@ -2620,6 +2619,8 @@ socket_spawn (rpc_transport_t *this) gf_log (this->name, GF_LOG_TRACE, "spawning %p with gen %u", this, priv->ot_gen); + GF_REF_GET (priv); + /* Create thread after enable detach flag */ ret = gf_thread_create_detached (&priv->thread, socket_poller, this); @@ -2877,9 +2878,10 @@ socket_disconnect (rpc_transport_t *this, gf_boolean_t wait) priv = this->private; if (wait && priv->own_thread) { + GF_REF_PUT (priv); + pthread_mutex_lock (&priv->cond_lock); { - GF_REF_PUT (priv); /* Change the state to OT_PLEASE_DIE so that * socket_poller can exit. */ priv->ot_state = OT_PLEASE_DIE; -- cgit