summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2012-05-02 14:23:27 +0530
committerVijay Bellur <vijay@gluster.com>2012-05-03 21:28:37 -0700
commit3b47032cbec05ebd90a73e362eaf2653789a09bc (patch)
tree692bbdff10f61ebe7466ea3f4b13979a90c504f5 /cli
parent5f48ad266195ec85171db48cf3dba83f98cbe728 (diff)
cli: fix remove-brick output behavior in failure cases
earlier it was dependant on server sending the dict for knowing the command. Now it preserves the dictionary in frame->local, which is used to understand the command. Change-Id: Ica675b497e466f77878f67792ae96b71f0704d6b Signed-off-by: Amar Tumballi <amarts@redhat.com> BUG: 815745 Reviewed-on: http://review.gluster.com/3235 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Shishir Gowda <shishirng@gluster.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-rpc-ops.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index b270c9c..da66af6 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -1601,27 +1601,24 @@ gf_cli3_1_remove_brick_cbk (struct rpc_req *req, struct iovec *iov,
int ret = -1;
char msg[1024] = {0,};
gf1_op_commands cmd = GF_OP_CMD_NONE;
- dict_t *dict = NULL;
char *cmd_str = "unknown";
+ cli_local_t *local = NULL;
+ call_frame_t *frame = NULL;
if (-1 == req->rpc_status) {
goto out;
}
+ frame = myframe;
+ local = frame->local;
+
ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
}
- dict = dict_new ();
-
- ret = dict_unserialize (rsp.dict.dict_val, rsp.dict.dict_len, &dict);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "failed to unserialize rsp to dict");
- goto out;
- }
- ret = dict_get_int32 (dict, "command", (int32_t *)&cmd);
+ ret = dict_get_int32 (local->dict, "command", (int32_t *)&cmd);
if (ret) {
gf_log ("", GF_LOG_ERROR, "failed to get command");
goto out;
@@ -1639,7 +1636,7 @@ gf_cli3_1_remove_brick_cbk (struct rpc_req *req, struct iovec *iov,
cmd_str = "commit force";
break;
default:
- cmd_str = "unkown";
+ cmd_str = "unknown";
break;
}
@@ -1668,13 +1665,19 @@ gf_cli3_1_remove_brick_cbk (struct rpc_req *req, struct iovec *iov,
ret = rsp.op_ret;
out:
+ if (frame)
+ frame->local = NULL;
+
+ if (local) {
+ dict_unref (local->dict);
+ cli_local_wipe (local);
+ }
+
cli_cmd_broadcast_response (ret);
if (rsp.dict.dict_val)
free (rsp.dict.dict_val);
if (rsp.op_errstr)
free (rsp.op_errstr);
- if (dict)
- dict_unref(dict);
return ret;
}
@@ -2937,14 +2940,27 @@ gf_cli3_1_remove_brick (call_frame_t *frame, xlator_t *this,
char *volname = NULL;
dict_t *req_dict = NULL;
int32_t cmd = 0;
+ cli_local_t *local = NULL;
if (!frame || !this || !data) {
ret = -1;
goto out;
}
+ local = cli_local_get ();
+ if (!local) {
+ ret = -1;
+ gf_log (this->name, GF_LOG_ERROR,
+ "Out of memory");
+ goto out;
+ }
+
+ frame->local = local;
+
dict = data;
+ local->dict = dict_ref (dict);
+
ret = dict_get_str (dict, "volname", &volname);
if (ret)
goto out;