From aa17ab8aa1851ac8848b0e36c420f6dd09fe9616 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Thu, 12 Aug 2010 01:47:38 +0000 Subject: rpc: Cleanup reconnect timer while destroying rpc_clnt Signed-off-by: Vijay Bellur Signed-off-by: Anand V. Avati BUG: 1334 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1334 --- rpc/rpc-lib/src/rpc-clnt.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 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 fce3e8200fe..dd28c60e0a5 100644 --- a/rpc/rpc-lib/src/rpc-clnt.c +++ b/rpc/rpc-lib/src/rpc-clnt.c @@ -429,6 +429,30 @@ out: return ret; } +int +rpc_clnt_reconnect_cleanup (rpc_clnt_connection_t *conn) +{ + struct rpc_clnt *clnt = NULL; + + if (!conn) { + goto out; + } + + clnt = conn->rpc_clnt; + + pthread_mutex_lock (&conn->lock); + { + + if (conn->reconnect) { + gf_timer_call_cancel (clnt->ctx, conn->reconnect); + conn->reconnect = NULL; + } + + } + +out: + return 0; +} /* * client_protocol_cleanup - cleanup function @@ -461,10 +485,6 @@ rpc_clnt_connection_cleanup (rpc_clnt_connection_t *conn) conn->timer = NULL; } - if (conn->reconnect == NULL) { - /* :O This part is empty.. any thing missing? */ - } - conn->connected = 0; } pthread_mutex_unlock (&conn->lock); @@ -1322,6 +1342,7 @@ void rpc_clnt_destroy (struct rpc_clnt *rpc) { rpc_clnt_connection_cleanup (&rpc->conn); + rpc_clnt_reconnect_cleanup (&rpc->conn); pthread_mutex_destroy (&rpc->lock); pthread_mutex_destroy (&rpc->conn.lock); GF_FREE (rpc); -- cgit