diff options
author | Kaushik BV <kaushikbv@gluster.com> | 2010-10-09 06:58:00 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-10-09 06:45:33 -0700 |
commit | 2eb9861cbc0387b1054bfeb7864c255a42b475f5 (patch) | |
tree | 3b06d67d794d798ce852566d3e6a7efe9a83781d /xlators/mgmt/glusterd/src/glusterd-op-sm.c | |
parent | afb6997fe74af257c7e687e33fe88a292f7a4a00 (diff) |
mgmt/Glusterd: Memory leak fixes, minor CLI changesv3.1.0qa44
Signed-off-by: Kaushik BV <kaushikbv@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 1852 (Usage message of volume set printed twice)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1852
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-op-sm.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 59 |
1 files changed, 32 insertions, 27 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 34caacd5ea8..75605e51ec9 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -1191,13 +1191,12 @@ glusterd_op_stage_set_volume (gd1_mgmt_stage_op_req *req, char **op_errstr) dict = dict_new (); if (!dict) goto out; - + val_dict = dict_new(); if (!val_dict) goto out; ret = dict_unserialize (req->buf.buf_val, req->buf.buf_len, &dict); - ret = dict_unserialize (req->buf.buf_val, req->buf.buf_len, &dict); if (ret) { gf_log ("", GF_LOG_ERROR, "Unable to unserialize dict"); @@ -1217,46 +1216,48 @@ glusterd_op_stage_set_volume (gd1_mgmt_stage_op_req *req, char **op_errstr) gf_log ("", GF_LOG_ERROR, "Volume with name: %s " "does not exist", volname); snprintf (errstr, 2048, "Volume : %s does not exist", - key); + volname); *op_errstr = gf_strdup (errstr); ret = -1; goto out; } - + ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { gf_log ("", GF_LOG_ERROR, "Unable to allocate memory"); goto out; } - + ret = dict_get_int32 (dict, "count", &dict_count); - + if (ret) { gf_log ("", GF_LOG_ERROR, "Count(dict),not set in Volume-Set"); goto out; } - + if ( dict_count == 1 ) { if (dict_get (dict, "history" )) { ret = 0; goto out; } - + gf_log ("", GF_LOG_ERROR, "No options received "); + *op_errstr = gf_strdup ("Options not specified"); ret = -1; goto out; } - - for ( count = 1; ret != -1 ; count++ ) { + + for ( count = 1; ret != 1 ; count++ ) { sprintf (str, "key%d", count); ret = dict_get_str (dict, str, &key); if (ret) - break; + break; + exists = glusterd_check_option_exists (key, NULL); @@ -1270,7 +1271,7 @@ glusterd_op_stage_set_volume (gd1_mgmt_stage_op_req *req, char **op_errstr) ret = -1; goto out; } - + sprintf (str, "value%d", count); ret = dict_get_str (dict, str, &value); @@ -1280,9 +1281,9 @@ glusterd_op_stage_set_volume (gd1_mgmt_stage_op_req *req, char **op_errstr) ret = -1; goto out; } - + ret = dict_set_str (val_dict, key, value); - + if (ret) { gf_log ("", GF_LOG_ERROR, "Unable to set the options" "in 'volume set'"); @@ -1306,20 +1307,24 @@ glusterd_op_stage_set_volume (gd1_mgmt_stage_op_req *req, char **op_errstr) ret = 0; out: - if (dict) + if (dict) dict_unref (dict); - if (ret) { - if (!(*op_errstr)) { - *op_errstr = gf_strdup ("Error, Validation Failed"); - gf_log ("glsuterd", GF_LOG_DEBUG, - "Error, Cannot Validate option :%s", - *op_errstr); - } - else - gf_log ("glsuterd", GF_LOG_DEBUG, - "Error, Cannot Validate option"); - } - return ret; + + if (val_dict) + dict_unref (val_dict); + + if (ret) { + if (!(*op_errstr)) { + *op_errstr = gf_strdup ("Error, Validation Failed"); + gf_log ("glsuterd", GF_LOG_DEBUG, + "Error, Cannot Validate option :%s", + *op_errstr); + } + else + gf_log ("glsuterd", GF_LOG_DEBUG, + "Error, Cannot Validate option"); + } +return ret; } static int |