From 81b671693c0015dd9f7acf818488118dbd61a6b0 Mon Sep 17 00:00:00 2001 From: Kevin Vigor Date: Fri, 16 Sep 2016 14:13:40 -0700 Subject: Fix deadlock observed in T13390459 Summary: Fix deadlock in ping timer callback. Test Plan: run, mount volume. Reviewers: rwareing Reviewed By: rwareing Differential Revision: https://phabricator.intern.facebook.com/D3744945 Signature: t1:3744945:1474061471:3e3d1a5cefc541d26973535887c1f08c017fc049 Change-Id: Iaf94eb4c3acaa8b3ceeeb6a273db4109eea29a7c Signed-off-by: Kevin Vigor Reviewed-on: http://review.gluster.org/16168 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Shreyas Siravara CentOS-regression: Gluster Build System --- rpc/rpc-lib/src/rpc-clnt-ping.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/rpc/rpc-lib/src/rpc-clnt-ping.c b/rpc/rpc-lib/src/rpc-clnt-ping.c index 91a2ab84140..d999adddb7f 100644 --- a/rpc/rpc-lib/src/rpc-clnt-ping.c +++ b/rpc/rpc-lib/src/rpc-clnt-ping.c @@ -187,6 +187,7 @@ rpc_clnt_ping_cbk (struct rpc_req *req, struct iovec *iov, int count, int64_t latency_msec = 0; int ret = 0; int unref = 0; + gf_boolean_t call_notify = _gf_false; if (!myframe) { gf_log (THIS->name, GF_LOG_WARNING, @@ -210,12 +211,6 @@ rpc_clnt_ping_cbk (struct rpc_req *req, struct iovec *iov, int count, "Ping latency is %" PRIu64 "ms", latency_msec); - ret = local->rpc->notifyfn (local->rpc, NULL, RPC_CLNT_PING, - NULL); - if (ret) - gf_log (this->name, GF_LOG_WARNING, - "RPC_CLNT_PING notify failed"); - if (req->rpc_status == -1) { unref = rpc_clnt_remove_ping_timer_locked (local->rpc); if (unref) { @@ -242,6 +237,15 @@ rpc_clnt_ping_cbk (struct rpc_req *req, struct iovec *iov, int count, } unlock: pthread_mutex_unlock (&conn->lock); + + if (call_notify) { + ret = local->rpc->notifyfn (local->rpc, this, + RPC_CLNT_PING, NULL); + if (ret) { + gf_log (this->name, GF_LOG_WARNING, + "RPC_CLNT_PING notify failed"); + } + } out: if (unref) rpc_clnt_unref (local->rpc); -- cgit