From 5441db69f8562a0daa9e6d82aa4279ded0d6e649 Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Tue, 2 Jun 2015 15:01:53 +0530 Subject: rpc: call transport_unref only on non-NULL transport BUG: 1227583 Change-Id: Ifac4dd8c633081483e4eba9d7e5a89837b2a453a Signed-off-by: Krishnan Parthasarathi Reviewed-on: http://review.gluster.org/11041 Tested-by: Gluster Build System Tested-by: NetBSD Build System Reviewed-by: Raghavendra G Tested-by: Raghavendra G --- rpc/rpc-lib/src/rpc-clnt.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'rpc') diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c index ebcfec73cef..567ff35b86a 100644 --- a/rpc/rpc-lib/src/rpc-clnt.c +++ b/rpc/rpc-lib/src/rpc-clnt.c @@ -1630,10 +1630,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 -- cgit