cb8e9e
From a3b6076b0ce30db7e9fdf42950f83f18a59c682b Mon Sep 17 00:00:00 2001
cb8e9e
From: Krishnan Parthasarathi <kparthas@redhat.com>
cb8e9e
Date: Tue, 2 Jun 2015 15:01:53 +0530
cb8e9e
Subject: [PATCH 26/57] rpc: call transport_unref only on non-NULL transport
cb8e9e
cb8e9e
BUG: 1222785
cb8e9e
Change-Id: Ifac4dd8c633081483e4eba9d7e5a89837b2a453a
cb8e9e
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
cb8e9e
Reviewed-on: http://review.gluster.org/11041
cb8e9e
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
cb8e9e
Reviewed-on: http://review.gluster.org/11102
cb8e9e
Reviewed-by: Niels de Vos <ndevos@redhat.com>
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/50388
cb8e9e
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
cb8e9e
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
cb8e9e
---
cb8e9e
 rpc/rpc-lib/src/rpc-clnt.c |   10 ++++++++--
cb8e9e
 1 files changed, 8 insertions(+), 2 deletions(-)
cb8e9e
cb8e9e
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
cb8e9e
index db99484..2878372 100644
cb8e9e
--- a/rpc/rpc-lib/src/rpc-clnt.c
cb8e9e
+++ b/rpc/rpc-lib/src/rpc-clnt.c
cb8e9e
@@ -1635,10 +1635,16 @@ rpc_clnt_trigger_destroy (struct rpc_clnt *rpc)
cb8e9e
         if (!rpc)
cb8e9e
                 return;
cb8e9e
 
cb8e9e
+        /* reading conn->trans outside conn->lock is OK, since this is the last
cb8e9e
+         * ref*/
cb8e9e
         conn = &rpc->conn;
cb8e9e
         trans = conn->trans;
cb8e9e
-        rpc_clnt_disable (rpc);
cb8e9e
-        rpc_transport_unref (trans);
cb8e9e
+        rpc_clnt_disconnect (rpc);
cb8e9e
+
cb8e9e
+        /* This is to account for rpc_clnt_disable that might have been called
cb8e9e
+         * before rpc_clnt_unref */
cb8e9e
+        if (trans)
cb8e9e
+                rpc_transport_unref (trans);
cb8e9e
 }
cb8e9e
 
cb8e9e
 static void
cb8e9e
-- 
cb8e9e
1.7.1
cb8e9e