summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-handler.c
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kparthas@redhat.com>2012-10-11 22:41:56 +0530
committerAnand Avati <avati@redhat.com>2012-10-11 11:58:33 -0700
commit1f2dbafc72e6b4942a47dacb3899665118d7ec6b (patch)
tree226177d56772aead79f6ad882d14d69f24fe4955 /xlators/mgmt/glusterd/src/glusterd-handler.c
parent751da4675cf3add21e567aebb92de2c10457afee (diff)
glusterd: Moved peer rsp handling functions to glusterd-utils
- Moved inner functions used in conjunction with synctask, 'out'. Change-Id: I7fbfd9881ea58645c4295a9fa7163ddd15a45d2f BUG: 862834 Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: http://review.gluster.org/4066 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-handler.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 13e53c17f6c..663cee307ee 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -266,10 +266,32 @@ out:
return ret;
}
+struct args_pack {
+ dict_t *dict;
+ int vol_count;
+ int opt_count;
+};
+
+static int
+_build_option_key (dict_t *d, char *k, data_t *v, void *tmp)
+{
+ char reconfig_key[256] = {0, };
+ struct args_pack *pack = NULL;
+ int ret = -1;
+
+ pack = tmp;
+ snprintf (reconfig_key, 256, "volume%d.option.%s",
+ pack->vol_count, k);
+ ret = dict_set_str (pack->dict, reconfig_key, v->data);
+ if (0 == ret)
+ pack->opt_count++;
+
+ return 0;
+}
int
glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo,
- dict_t *volumes, int count)
+ dict_t *volumes, int count)
{
int ret = -1;
@@ -277,11 +299,10 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *brickinfo = NULL;
char *buf = NULL;
int i = 1;
- char reconfig_key[256] = {0, };
dict_t *dict = NULL;
- int opt_count = 0;
glusterd_conf_t *priv = NULL;
char *volume_id_str = NULL;
+ struct args_pack pack = {0,};
GF_ASSERT (volinfo);
@@ -363,18 +384,13 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo,
goto out;
}
- int _build_option_key (dict_t *d, char *k, data_t *v, void *tmp)
- {
- snprintf (reconfig_key, 256, "volume%d.option.%s", count, k);
- ret = dict_set_str (volumes, reconfig_key, v->data);
- if (0 == ret)
- opt_count++;
- return 0;
- }
- dict_foreach (dict, _build_option_key, NULL);
+ pack.dict = volumes;
+ pack.vol_count = count;
+ pack.opt_count = 0;
+ dict_foreach (dict, _build_option_key, (void *) &pack);
- snprintf (key, 256, "volume%d.opt_count", count);
- ret = dict_set_int32 (volumes, key, opt_count);
+ snprintf (key, 256, "volume%d.opt_count", pack.vol_count);
+ ret = dict_set_int32 (volumes, key, pack.opt_count);
out:
return ret;
}