From 2323b92d9b7b679c84cab64697fc715434e28ac9 Mon Sep 17 00:00:00 2001 From: "Anand V. Avati" Date: Tue, 10 Mar 2009 00:27:52 +0530 Subject: failover to any active transport when requested channel is not connected Signed-off-by: Anand V. Avati --- xlators/protocol/client/src/client-protocol.c | 28 +++++++++++++++++++++++++++ xlators/protocol/client/src/client-protocol.h | 4 ++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/xlators/protocol/client/src/client-protocol.c b/xlators/protocol/client/src/client-protocol.c index 2a636a18fef..95a5db89590 100644 --- a/xlators/protocol/client/src/client-protocol.c +++ b/xlators/protocol/client/src/client-protocol.c @@ -61,6 +61,34 @@ static gf_op_t gf_mops[]; static gf_op_t gf_cbks[]; +transport_t * +client_channel (xlator_t *this, int id) +{ + transport_t *trans = NULL; + client_conf_t *conf = NULL; + int i = 0; + struct client_connection *conn = NULL; + + conf = this->private; + + trans = conf->transport[id]; + conn = trans->xl_private; + + if (conn->connected == 1) + goto ret; + + for (i = 0; i < CHANNEL_MAX; i++) { + trans = conf->transport[i]; + conn = trans->xl_private; + if (conn->connected == 1) + break; + } + +ret: + return trans; +} + + static ino_t this_ino_get_from_inode (inode_t *inode, xlator_t *this) { diff --git a/xlators/protocol/client/src/client-protocol.h b/xlators/protocol/client/src/client-protocol.h index 513267d3783..ce8cd516953 100644 --- a/xlators/protocol/client/src/client-protocol.h +++ b/xlators/protocol/client/src/client-protocol.h @@ -54,8 +54,8 @@ enum { CHANNEL_LOWLAT = 1, CHANNEL_MAX }; -#define CLIENT_CHANNEL(xl,id) \ - (((client_conf_t *)(xl->private))->transport[id]) + +#define CLIENT_CHANNEL client_channel struct client_connection; typedef struct client_connection client_connection_t; -- cgit