Blob Blame History Raw
From a3b6076b0ce30db7e9fdf42950f83f18a59c682b Mon Sep 17 00:00:00 2001
From: Krishnan Parthasarathi <kparthas@redhat.com>
Date: Tue, 2 Jun 2015 15:01:53 +0530
Subject: [PATCH 26/57] rpc: call transport_unref only on non-NULL transport

BUG: 1222785
Change-Id: Ifac4dd8c633081483e4eba9d7e5a89837b2a453a
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-on: http://review.gluster.org/11041
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Reviewed-on: http://review.gluster.org/11102
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/50388
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
---
 rpc/rpc-lib/src/rpc-clnt.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
index db99484..2878372 100644
--- a/rpc/rpc-lib/src/rpc-clnt.c
+++ b/rpc/rpc-lib/src/rpc-clnt.c
@@ -1635,10 +1635,16 @@ rpc_clnt_trigger_destroy (struct rpc_clnt *rpc)
         if (!rpc)
                 return;
 
+        /* reading conn->trans outside conn->lock is OK, since this is the last
+         * ref*/
         conn = &rpc->conn;
         trans = conn->trans;
-        rpc_clnt_disable (rpc);
-        rpc_transport_unref (trans);
+        rpc_clnt_disconnect (rpc);
+
+        /* This is to account for rpc_clnt_disable that might have been called
+         * before rpc_clnt_unref */
+        if (trans)
+                rpc_transport_unref (trans);
 }
 
 static void
-- 
1.7.1