From 2339b9e87e8e48df9b64ba016949a2f40b50324e Mon Sep 17 00:00:00 2001 From: Pranith K Date: Wed, 23 Mar 2011 21:44:13 +0000 Subject: mgmt/glusterd: Avoid printing no-error message to user when op fails - Prints the peer hostname/uuid where the error happened in case the peer does not return an error string. Signed-off-by: Pranith Kumar K Signed-off-by: Vijay Bellur BUG: 2585 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2585 --- xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 29 +++++++++++++++++++++++++--- xlators/mgmt/glusterd/src/glusterd-store.c | 1 + 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c index 43a0f22c71c..05637874919 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c @@ -895,6 +895,8 @@ glusterd3_1_stage_op_cbk (struct rpc_req *req, struct iovec *iov, glusterd_op_sm_event_type_t event_type = GD_OP_EVENT_NONE; glusterd_peerinfo_t *peerinfo = NULL; dict_t *dict = NULL; + char err_str[2048] = {0}; + char *peer_str = NULL; GF_ASSERT (req); @@ -948,8 +950,17 @@ glusterd3_1_stage_op_cbk (struct rpc_req *req, struct iovec *iov, if (op_ret) { event_type = GD_OP_EVENT_RCVD_RJT; opinfo.op_ret = op_ret; - if (strcmp ("", rsp.op_errstr)) - opinfo.op_errstr = gf_strdup(rsp.op_errstr); + if (strcmp ("", rsp.op_errstr)) { + opinfo.op_errstr = gf_strdup (rsp.op_errstr); + } else { + if (peerinfo) + peer_str = peerinfo->hostname; + else + peer_str = uuid_utoa (rsp.uuid); + snprintf (err_str, sizeof (err_str), "Operation failed " + "on %s", peer_str); + opinfo.op_errstr = gf_strdup (err_str); + } if (!opinfo.op_errstr) { gf_log ("", GF_LOG_ERROR, "memory allocation failed"); ret = -1; @@ -1067,6 +1078,8 @@ glusterd3_1_commit_op_cbk (struct rpc_req *req, struct iovec *iov, glusterd_op_sm_event_type_t event_type = GD_OP_EVENT_NONE; glusterd_peerinfo_t *peerinfo = NULL; dict_t *dict = NULL; + char err_str[2048] = {0}; + char *peer_str = NULL; GF_ASSERT (req); @@ -1123,7 +1136,17 @@ glusterd3_1_commit_op_cbk (struct rpc_req *req, struct iovec *iov, if (op_ret) { event_type = GD_OP_EVENT_RCVD_RJT; opinfo.op_ret = op_ret; - opinfo.op_errstr = gf_strdup(rsp.op_errstr); + if (strcmp ("", rsp.op_errstr)) { + opinfo.op_errstr = gf_strdup(rsp.op_errstr); + } else { + if (peerinfo) + peer_str = peerinfo->hostname; + else + peer_str = uuid_utoa (rsp.uuid); + snprintf (err_str, sizeof (err_str), "Operation failed " + "on %s", peer_str); + opinfo.op_errstr = gf_strdup (err_str); + } if (!opinfo.op_errstr) { gf_log ("", GF_LOG_ERROR, "memory allocation failed"); ret = -1; diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 96af05d802e..e1db5f4546e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -1912,6 +1912,7 @@ glusterd_store_retrieve_peers (xlator_t *this) ret = glusterd_friend_add (hostname, 0, state, &uuid, NULL, &peerinfo, 1, &args); + GF_FREE (hostname); if (ret) goto out; -- cgit