From 9d842f965655bf70c643b4541844e83bc4e74190 Mon Sep 17 00:00:00 2001 From: Atin Mukherjee Date: Wed, 11 Feb 2015 17:13:45 +0530 Subject: glusterd: nfs,shd,quotad,snapd daemons refactoring This patch ports nfs, shd, quotad & snapd with the approach suggested in http://www.gluster.org/pipermail/gluster-devel/2014-December/043180.html Change-Id: I4ea5b38793f87fc85cc9d2cf873727351dedffd2 BUG: 1191486 Signed-off-by: Atin Mukherjee Signed-off-by: Krishnan Parthasarathi Reviewed-on: http://review.gluster.org/9428 Tested-by: Gluster Build System Reviewed-by: Anand Nekkunti --- rpc/rpc-lib/src/rpc-clnt.c | 41 +++++++++++++++++++++++++++++++++++++++++ rpc/rpc-lib/src/rpc-clnt.h | 3 +++ 2 files changed, 44 insertions(+) (limited to 'rpc') diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c index 4c8333b7d5d..20981ef9c9c 100644 --- a/rpc/rpc-lib/src/rpc-clnt.c +++ b/rpc/rpc-lib/src/rpc-clnt.c @@ -1744,6 +1744,47 @@ out: return; } +void +rpc_clnt_disconnect (struct rpc_clnt *rpc) +{ + rpc_clnt_connection_t *conn = NULL; + rpc_transport_t *trans = NULL; + + if (!rpc) + goto out; + + conn = &rpc->conn; + + pthread_mutex_lock (&conn->lock); + { + if (conn->timer) { + gf_timer_call_cancel (rpc->ctx, conn->timer); + conn->timer = NULL; + } + + if (conn->reconnect) { + gf_timer_call_cancel (rpc->ctx, conn->reconnect); + conn->reconnect = NULL; + } + conn->connected = 0; + + if (conn->ping_timer) { + gf_timer_call_cancel (rpc->ctx, conn->ping_timer); + conn->ping_timer = NULL; + conn->ping_started = 0; + } + trans = conn->trans; + } + pthread_mutex_unlock (&conn->lock); + + if (trans) { + rpc_transport_disconnect (trans); + } + +out: + return; +} + void rpc_clnt_reconfig (struct rpc_clnt *rpc, struct rpc_clnt_config *config) diff --git a/rpc/rpc-lib/src/rpc-clnt.h b/rpc/rpc-lib/src/rpc-clnt.h index 6492a81f24e..faae4855a6c 100644 --- a/rpc/rpc-lib/src/rpc-clnt.h +++ b/rpc/rpc-lib/src/rpc-clnt.h @@ -244,6 +244,9 @@ int rpcclnt_cbk_program_register (struct rpc_clnt *svc, void rpc_clnt_disable (struct rpc_clnt *rpc); +void +rpc_clnt_disconnect (struct rpc_clnt *rpc); + char rpc_clnt_is_disabled (struct rpc_clnt *rpc); -- cgit