diff options
author | Pranith Kumar K <pranithk@gluster.com> | 2012-03-16 11:35:36 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-03-17 23:24:21 -0700 |
commit | 178652106c5d731b24ddc9bb9bc1d8aae3952e2d (patch) | |
tree | f13fd78316ef9685fd7e2fcf8adc4b2a33c26e60 /glusterfsd | |
parent | 6aab9d9602dc1ef62a2d1d63aa1764a062bf9d9f (diff) | |
download | glusterfs-178652106c5d731b24ddc9bb9bc1d8aae3952e2d.tar.gz glusterfs-178652106c5d731b24ddc9bb9bc1d8aae3952e2d.tar.xz glusterfs-178652106c5d731b24ddc9bb9bc1d8aae3952e2d.zip |
glusterfsd: Handle errors in response send
Change-Id: I2d0a136fdfc4c86fb89cff5565efbf4af80e1edf
BUG: 799265
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/2961
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'glusterfsd')
-rw-r--r-- | glusterfsd/src/glusterfsd-mgmt.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c index e45297d50d..3b419262ac 100644 --- a/glusterfsd/src/glusterfsd-mgmt.c +++ b/glusterfsd/src/glusterfsd-mgmt.c @@ -235,23 +235,28 @@ glusterfs_translator_info_response_send (rpcsvc_request_t *req, int ret, char *msg, dict_t *output) { gd1_mgmt_brick_op_rsp rsp = {0,}; - GF_ASSERT (msg); + gf_boolean_t free_ptr = _gf_false; GF_ASSERT (req); - GF_ASSERT (output); rsp.op_ret = ret; rsp.op_errno = 0; - if (ret && msg[0]) + if (ret && msg && msg[0]) rsp.op_errstr = msg; else rsp.op_errstr = ""; - ret = dict_allocate_and_serialize (output, &rsp.output.output_val, - (size_t *)&rsp.output.output_len); + ret = -1; + if (output) { + ret = dict_allocate_and_serialize (output, + &rsp.output.output_val, + (size_t *)&rsp.output.output_len); + } + if (!ret) + free_ptr = _gf_true; ret = glusterfs_submit_reply (req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gd1_mgmt_brick_op_rsp); - if (rsp.output.output_val) + if (free_ptr) GF_FREE (rsp.output.output_val); return ret; } @@ -323,30 +328,28 @@ glusterfs_xlator_op_response_send (rpcsvc_request_t *req, int op_ret, { gd1_mgmt_brick_op_rsp rsp = {0,}; int ret = -1; - GF_ASSERT (msg); + gf_boolean_t free_ptr = _gf_false; GF_ASSERT (req); - GF_ASSERT (output); rsp.op_ret = op_ret; rsp.op_errno = 0; - if (ret && msg[0]) + if (op_ret && msg && msg[0]) rsp.op_errstr = msg; else rsp.op_errstr = ""; - ret = dict_allocate_and_serialize (output, &rsp.output.output_val, - (size_t *)&rsp.output.output_len); - if (ret) { - gf_log (THIS->name, GF_LOG_ERROR, "Couldn't serialize " - "output dict."); - goto out; + if (output) { + ret = dict_allocate_and_serialize (output, + &rsp.output.output_val, + (size_t *)&rsp.output.output_len); } + if (!ret) + free_ptr = _gf_true; ret = glusterfs_submit_reply (req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gd1_mgmt_brick_op_rsp); -out: - if (rsp.output.output_val) + if (free_ptr) GF_FREE (rsp.output.output_val); return ret; |