From 34be428d5640a0ad4c47a05ee3e716189b4a54ed Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Thu, 25 Aug 2011 17:51:18 +0530 Subject: glusterd: fail the 'peer probe' if the first connect attempt fails so 'gluster peer probe' command doesn't hang till timeout (120s), instead it will send the proper error msg to client. Change-Id: I398fa16d526f869f1d27eeb57aeb7ee4451fbecd BUG: 1852 Reviewed-on: http://review.gluster.com/342 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/mgmt/glusterd/src/glusterd-handler.c | 52 +++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 4 deletions(-) (limited to 'xlators/mgmt/glusterd/src') diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 881e842142a..0547694ca65 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -2414,6 +2414,40 @@ glusterd_brick_rpc_notify (struct rpc_clnt *rpc, void *mydata, return ret; } +int +glusterd_friend_remove_notify (glusterd_peerinfo_t *peerinfo, rpcsvc_request_t *req) +{ + int ret = -1; + glusterd_friend_sm_event_t *new_event = NULL; + + ret = glusterd_friend_sm_new_event (GD_FRIEND_EVENT_REMOVE_FRIEND, + &new_event); + if (!ret) { + new_event->peerinfo = peerinfo; + ret = glusterd_friend_sm_inject_event (new_event); + + glusterd_friend_sm (); + glusterd_op_sm (); + + if (!req) { + gf_log (THIS->name, GF_LOG_WARNING, + "Unable to find the request for responding " + "to User (%s)", peerinfo->hostname); + goto out; + } + + glusterd_xfer_cli_probe_resp (req, -1, ENOTCONN, + peerinfo->hostname, peerinfo->port); + } else { + gf_log ("glusterd", GF_LOG_ERROR, + "Unable to create event for removing peer %s", + peerinfo->hostname); + } + +out: + return ret; +} + int glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, @@ -2448,10 +2482,10 @@ glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata, } case RPC_CLNT_DISCONNECT: + { + gf_log (this->name, GF_LOG_DEBUG, "got RPC_CLNT_DISCONNECT %d", + peerinfo->state.state); - //Inject friend disconnected here - - gf_log (this->name, GF_LOG_DEBUG, "got RPC_CLNT_DISCONNECT"); peerinfo->connected = 0; /* @@ -2482,9 +2516,19 @@ glusterd_peer_rpc_notify (struct rpc_clnt *rpc, void *mydata, gf_log (this->name, GF_LOG_ERROR, "Unable" " to enque local lock flush event."); + //Inject friend disconnected here + if (peerinfo->state.state == GD_FRIEND_STATE_DEFAULT) { + /* Remove the friend as it was the newly requested + 'peer' and connection with this peer didn't + succeed. we have opportunity to notify user + */ + glusterd_friend_remove_notify (peerinfo, + peerctx->args.req); + } + //default_notify (this, GF_EVENT_CHILD_DOWN, NULL); break; - + } default: gf_log (this->name, GF_LOG_TRACE, "got some other RPC event %d", event); -- cgit