From 108e4f3481225f98c12f7c283e1ef0388863cf8b Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Thu, 28 Mar 2019 11:03:34 +0530 Subject: rpc: Remove duplicate code rpc_clnt_disable() and rpc_clnt_disconnect() have same code. Removed rpc_clnt_disconnect() and moved calls to rpc_clnt_disconnect() to rpc_clnt_disable() updates bz#1193929 Change-Id: I965f57cc1d5af36d266810125558b6f5e5f279d4 Signed-off-by: Pranith Kumar K --- rpc/rpc-lib/src/rpc-clnt.c | 74 +--------------------------------------------- 1 file changed, 1 insertion(+), 73 deletions(-) (limited to 'rpc/rpc-lib/src/rpc-clnt.c') diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c index b04eaed40d2..8ef05378351 100644 --- a/rpc/rpc-lib/src/rpc-clnt.c +++ b/rpc/rpc-lib/src/rpc-clnt.c @@ -1786,7 +1786,7 @@ rpc_clnt_trigger_destroy(struct rpc_clnt *rpc) * ref*/ conn = &rpc->conn; trans = conn->trans; - rpc_clnt_disconnect(rpc); + rpc_clnt_disable(rpc); /* This is to account for rpc_clnt_disable that might have been called * before rpc_clnt_unref */ @@ -1933,78 +1933,6 @@ out: return; } -void -rpc_clnt_disconnect(struct rpc_clnt *rpc) -{ - rpc_clnt_connection_t *conn = NULL; - rpc_transport_t *trans = NULL; - int unref = 0; - int ret = 0; - gf_boolean_t timer_unref = _gf_false; - gf_boolean_t reconnect_unref = _gf_false; - - if (!rpc) - goto out; - - conn = &rpc->conn; - - pthread_mutex_lock(&conn->lock); - { - rpc->disabled = 1; - if (conn->timer) { - ret = gf_timer_call_cancel(rpc->ctx, conn->timer); - /* If the event is not fired and it actually cancelled - * the timer, do the unref else registered call back - * function will take care of unref. - */ - if (!ret) - timer_unref = _gf_true; - conn->timer = NULL; - } - - if (conn->reconnect) { - ret = gf_timer_call_cancel(rpc->ctx, conn->reconnect); - if (!ret) - reconnect_unref = _gf_true; - conn->reconnect = NULL; - } - conn->connected = 0; - - unref = rpc_clnt_remove_ping_timer_locked(rpc); - trans = conn->trans; - } - pthread_mutex_unlock(&conn->lock); - - if (trans) { - rpc_transport_disconnect(trans, _gf_true); - /* The auth_value was being reset to AUTH_GLUSTERFS_v2. - * if (clnt->auth_value) - * clnt->auth_value = AUTH_GLUSTERFS_v2; - * It should not be reset here. The disconnect during - * portmap request can race with handshake. If handshake - * happens first and disconnect later, auth_value would set - * to default value and it never sets back to actual auth_value - * supported by server. But it's important to set to lower - * version supported in the case where the server downgrades. - * So moving this code to RPC_TRANSPORT_CONNECT. Note that - * CONNECT cannot race with handshake as by nature it is - * serialized with handhake. An handshake can happen only - * on a connected transport and hence its strictly serialized. - */ - } - if (unref) - rpc_clnt_unref(rpc); - - if (timer_unref) - rpc_clnt_unref(rpc); - - if (reconnect_unref) - rpc_clnt_unref(rpc); - -out: - return; -} - void rpc_clnt_reconfig(struct rpc_clnt *rpc, struct rpc_clnt_config *config) { -- cgit