summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorZhang Huan <zhanghuan@open-fs.com>2018-01-24 16:06:08 +0800
committergluster-ant <bugzilla-bot@gluster.org>2018-01-24 16:06:08 +0800
commitb585e5021f655dc9b971de85480fe31ba6502521 (patch)
tree723d22fdb247153fd1f365702771fa579cb451e1 /rpc
parent39b39196b1719f8a8c0c7acf2452420ebe8a705c (diff)
downloadglusterfs-b585e5021f655dc9b971de85480fe31ba6502521.tar.gz
glusterfs-b585e5021f655dc9b971de85480fe31ba6502521.tar.xz
glusterfs-b585e5021f655dc9b971de85480fe31ba6502521.zip
rpc: fix missing unref on reconnect
On protocol client connecting to brick, client will firstly contact glusterd to get port, then reconnect to glusterfsd. Reconnect cancels the reconnect timer and start a new one. However, cancelling the timer does not unref rpc ref-ed for it. That leads to refcount leak. Fix this issue by unref-ing rpc if reconnect timer is canceled. Change-Id: Ice89dcd93cb283a0c7250c369cc8961d52fb2022 Fixes: bz#1538900 BUG: 1538900 Signed-off-by: Zhang Huan <zhanghuan@open-fs.com>
Diffstat (limited to 'rpc')
-rw-r--r--rpc/rpc-lib/src/rpc-clnt.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
index aa65a1f876..dac707664d 100644
--- a/rpc/rpc-lib/src/rpc-clnt.c
+++ b/rpc/rpc-lib/src/rpc-clnt.c
@@ -376,19 +376,20 @@ rpc_clnt_reconnect(void *conn_ptr)
struct timespec ts = {0, 0};
struct rpc_clnt *clnt = NULL;
gf_boolean_t need_unref = _gf_false;
+ gf_boolean_t canceled_unref = _gf_false;
conn = conn_ptr;
clnt = conn->rpc_clnt;
-
pthread_mutex_lock(&conn->lock);
{
trans = conn->trans;
- if (!trans) {
- pthread_mutex_unlock(&conn->lock);
- return;
+ if (!trans)
+ goto out_unlock;
+
+ if (conn->reconnect) {
+ if (!gf_timer_call_cancel(clnt->ctx, conn->reconnect))
+ canceled_unref = _gf_true;
}
- if (conn->reconnect)
- gf_timer_call_cancel(clnt->ctx, conn->reconnect);
conn->reconnect = 0;
if ((conn->connected == 0) && !clnt->disabled) {
@@ -409,11 +410,14 @@ rpc_clnt_reconnect(void *conn_ptr)
gf_log(conn->name, GF_LOG_TRACE, "breaking reconnect chain");
}
}
+out_unlock:
pthread_mutex_unlock(&conn->lock);
rpc_clnt_unref(clnt);
if (need_unref)
rpc_clnt_unref(clnt);
+ if (canceled_unref)
+ rpc_clnt_unref(clnt);
return;
}