From 0caffe52b8db6670dfa2b1c825477ede7ba304c6 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Tue, 1 May 2012 10:50:50 +0530 Subject: protocol/client: hold lock when cancelling ping_timer in client_ping_cbk. Change-Id: I2b4e723ef119c62902f8a692a8a1f424da0d08b4 BUG: 816951 Signed-off-by: Raghavendra G Reviewed-on: http://review.gluster.com/3254 Tested-by: Gluster Build System Reviewed-by: Jeff Darcy Reviewed-by: Anand Avati --- xlators/protocol/client/src/client-handshake.c | 38 +++++++++++++++----------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index a3cb325b02a..c249516a930 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -254,35 +254,40 @@ client_ping_cbk (struct rpc_req *req, struct iovec *iov, int count, clnt_conf_t *conf = NULL; if (!myframe) { - gf_log (THIS->name, GF_LOG_WARNING, "frame with the request is NULL"); + gf_log (THIS->name, GF_LOG_WARNING, + "frame with the request is NULL"); goto out; } frame = myframe; this = frame->this; if (!this || !this->private) { - gf_log (THIS->name, GF_LOG_WARNING, "xlator private is not set"); + gf_log (THIS->name, GF_LOG_WARNING, + "xlator private is not set"); goto out; } conf = this->private; conn = &conf->rpc->conn; - if (req->rpc_status == -1) { - if (conn->ping_timer != NULL) { - gf_log (this->name, GF_LOG_WARNING, "socket or ib" - " related error"); - gf_timer_call_cancel (this->ctx, conn->ping_timer); - conn->ping_timer = NULL; - } else { - /* timer expired and transport bailed out */ - gf_log (this->name, GF_LOG_WARNING, "timer must have " - "expired"); - } - goto out; - } - pthread_mutex_lock (&conn->lock); { + if (req->rpc_status == -1) { + if (conn->ping_timer != NULL) { + gf_log (this->name, GF_LOG_WARNING, + "socket or ib related error"); + gf_timer_call_cancel (this->ctx, + conn->ping_timer); + conn->ping_timer = NULL; + } else { + /* timer expired and transport bailed out */ + gf_log (this->name, GF_LOG_WARNING, + "timer must have expired"); + } + + goto unlock; + } + + timeout.tv_sec = conf->opt.ping_timeout; timeout.tv_usec = 0; @@ -297,6 +302,7 @@ client_ping_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_log (this->name, GF_LOG_WARNING, "failed to set the ping timer"); } +unlock: pthread_mutex_unlock (&conn->lock); out: if (frame) -- cgit