From 6e90ebabd5f32233a1c01ee6edd2a2b88bcd38fd Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Thu, 20 Aug 2009 18:36:04 +0000 Subject: protocol/client: 'connecting' event is properly notified. when there are no servers available to client, and transport init is not successful, send 'connecting' event once to parent so it doesn't hand in there. Signed-off-by: Anand V. Avati BUG: 224 (Client hangs if none of the servers are up) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=224 --- xlators/protocol/client/src/client-protocol.c | 26 ++++++++++++++++++++++---- xlators/protocol/client/src/client-protocol.h | 1 + 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'xlators/protocol') diff --git a/xlators/protocol/client/src/client-protocol.c b/xlators/protocol/client/src/client-protocol.c index 505ded782..5f34ab3e6 100644 --- a/xlators/protocol/client/src/client-protocol.c +++ b/xlators/protocol/client/src/client-protocol.c @@ -5458,6 +5458,7 @@ int client_setvolume_cbk (call_frame_t *frame, gf_hdr_common_t *hdr, size_t hdrlen, struct iobuf *iobuf) { + client_conf_t *conf = NULL; gf_mop_setvolume_rsp_t *rsp = NULL; client_connection_t *conn = NULL; glusterfs_ctx_t *ctx = NULL; @@ -5475,10 +5476,10 @@ client_setvolume_cbk (call_frame_t *frame, gf_hdr_common_t *hdr, size_t hdrlen, transport_t *peer_trans = NULL; uint64_t peer_trans_int = 0; - trans = frame->local; frame->local = NULL; this = frame->this; conn = trans->xl_private; + conf = this->private; rsp = gf_param (hdr); @@ -5573,7 +5574,9 @@ client_setvolume_cbk (call_frame_t *frame, gf_hdr_common_t *hdr, size_t hdrlen, } } + conf->connecting = 0; out: + if (-1 == op_ret) { /* Let the connection/re-connection happen in * background, for now, don't hang here, @@ -5586,6 +5589,7 @@ out: trans->xl); parent = parent->next; } + conf->connecting= 1; } STACK_DESTROY (frame->root); @@ -6196,7 +6200,6 @@ notify (xlator_t *this, int32_t event, void *data, ...) client_connection_t *conn = NULL; client_conf_t *conf = NULL; xlator_list_t *parent = NULL; - conf = this->private; trans = data; @@ -6220,6 +6223,21 @@ notify (xlator_t *this, int32_t event, void *data, ...) ret = -1; protocol_client_cleanup (trans); + if (conf->connecting == 0) { + /* Let the connection/re-connection happen in + * background, for now, don't hang here, + * tell the parents that i am all ok.. + */ + parent = trans->xl->parents; + while (parent) { + parent->xlator->notify (parent->xlator, + GF_EVENT_CHILD_CONNECTING, + trans->xl); + parent = parent->next; + } + conf->connecting = 1; + } + was_not_down = 0; for (i = 0; i < CHANNEL_MAX; i++) { conn = conf->transport[i]->xl_private; @@ -6241,10 +6259,10 @@ notify (xlator_t *this, int32_t event, void *data, ...) if (conn->connected == 1) child_down = 0; } - + if (child_down && was_not_down) { gf_log (this->name, GF_LOG_INFO, "disconnected"); - + protocol_client_mark_fd_bad (this); parent = this->parents; diff --git a/xlators/protocol/client/src/client-protocol.h b/xlators/protocol/client/src/client-protocol.h index 86107f9bc..210e6d478 100644 --- a/xlators/protocol/client/src/client-protocol.h +++ b/xlators/protocol/client/src/client-protocol.h @@ -92,6 +92,7 @@ struct _client_conf { struct timeval last_sent; struct timeval last_received; pthread_mutex_t mutex; + int connecting; }; typedef struct _client_conf client_conf_t; -- cgit