From 37edb3fb56e2612e218b9f29424b4b6a79d18a94 Mon Sep 17 00:00:00 2001
From: Atin Mukherjee <amukherj@redhat.com>
Date: Sat, 18 Mar 2017 16:29:10 +0530
Subject: [PATCH 305/316] rpc: bump up conn->cleanup_gen in
rpc_clnt_reconnect_cleanup
Commit 086436a introduced generation number (cleanup_gen) to ensure that
rpc layer doesn't end up cleaning up the connection object if
application layer has already destroyed it. Bumping up cleanup_gen was
done only in rpc_clnt_connection_cleanup (). However the same is needed
in rpc_clnt_reconnect_cleanup () too as with out it if the object gets destroyed
through the reconnect event in the application layer, rpc layer will
still end up in trying to delete the object resulting into double free
and crash.
Peer probing an invalid host/IP was the basic test to catch this issue.
>Reviewed-on: https://review.gluster.org/16914
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
>Reviewed-by: Milind Changire <mchangir@redhat.com>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
Change-Id: Id5332f3239cb324cead34eb51cf73d426733bd46
BUG: 1440162
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/102946
---
rpc/rpc-lib/src/rpc-clnt.c | 4 +++-
.../glusterd/bug-1433578-invalid-peer-glusterd-crash.t | 14 ++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
create mode 100644 tests/bugs/glusterd/bug-1433578-invalid-peer-glusterd-crash.t
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
index 7bd4495..02045e1 100644
--- a/rpc/rpc-lib/src/rpc-clnt.c
+++ b/rpc/rpc-lib/src/rpc-clnt.c
@@ -495,8 +495,10 @@ rpc_clnt_reconnect_cleanup (rpc_clnt_connection_t *conn)
if (conn->reconnect) {
ret = gf_timer_call_cancel (clnt->ctx, conn->reconnect);
- if (!ret)
+ if (!ret) {
reconnect_unref = _gf_true;
+ conn->cleanup_gen++;
+ }
conn->reconnect = NULL;
}
diff --git a/tests/bugs/glusterd/bug-1433578-invalid-peer-glusterd-crash.t b/tests/bugs/glusterd/bug-1433578-invalid-peer-glusterd-crash.t
new file mode 100644
index 0000000..1aea8bc
--- /dev/null
+++ b/tests/bugs/glusterd/bug-1433578-invalid-peer-glusterd-crash.t
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+. $(dirname $0)/../../include.rc
+
+cleanup;
+
+## Start glusterd
+TEST glusterd;
+TEST pidof glusterd;
+
+TEST ! $CLI peer probe invalid-peer
+
+TEST pidof glusterd;
+cleanup;
--
1.8.3.1