summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2010-08-31 12:52:34 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-08-31 11:31:23 -0700
commit70652df2f7780aa734119941ac54d88ae6de7ae9 (patch)
tree96928b36d2412c211846e52d73dd2b3fb45b420f /xlators
parente7cbae70c89c8813918d9deb3895cb6886cdaeeb (diff)
mgmt/glusterd: memory leak fixes
Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1186 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1186
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c49
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handshake.c7
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-mem-types.h70
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c69
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-sm.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c25
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.h4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c9
-rw-r--r--xlators/mgmt/glusterd/src/glusterd3_1-mops.c11
9 files changed, 180 insertions, 66 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 42acfcc14f6..28812538f55 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -612,6 +612,8 @@ glusterd_handle_cli_list_friends (rpcsvc_request_t *req)
ret = glusterd_list_friends (req, dict, cli_req.flags);
out:
+ if (dict)
+ dict_unref (dict);
return ret;
}
@@ -993,6 +995,8 @@ glusterd_handle_cli_get_volume (rpcsvc_request_t *req)
ret = glusterd_get_volumes (req, dict, cli_req.flags);
out:
+ if (dict)
+ dict_unref (dict);
return ret;
}
@@ -1002,23 +1006,24 @@ glusterd_handle_create_volume (rpcsvc_request_t *req)
int32_t ret = -1;
gf1_cli_create_vol_req cli_req = {0,};
dict_t *dict = NULL;
- glusterd_brickinfo_t *brickinfo = NULL;
- char *brick = NULL;
- char *bricks = NULL;
- char *volname = NULL;
- int brick_count = 0;
- char *tmpptr = NULL;
- int i = 0;
- glusterd_peerinfo_t *peerinfo = NULL;
- char *brick_list = NULL;
- void *cli_rsp = NULL;
- char err_str[1048];
- gf1_cli_create_vol_rsp rsp = {0,};
+ glusterd_brickinfo_t *brickinfo = NULL;
+ char *brick = NULL;
+ char *bricks = NULL;
+ char *volname = NULL;
+ int brick_count = 0;
+ char *tmpptr = NULL;
+ int i = 0;
+ glusterd_peerinfo_t *peerinfo = NULL;
+ char *brick_list = NULL;
+ void *cli_rsp = NULL;
+ char err_str[1048];
+ gf1_cli_create_vol_rsp rsp = {0,};
glusterd_conf_t *priv = NULL;
int err_ret = 0;
glusterd_brickinfo_t *tmpbrkinfo = NULL;
glusterd_volinfo_t *volinfo = NULL;
xlator_t *this = NULL;
+ char *free_ptr = NULL;
GF_ASSERT (req);
this = THIS;
@@ -1077,8 +1082,10 @@ glusterd_handle_create_volume (rpcsvc_request_t *req)
goto out;
}
- if (bricks)
+ if (bricks) {
brick_list = gf_strdup (bricks);
+ free_ptr = brick_list;
+ }
gf_cmd_log ("Volume create", "volname: %s type:%s count:%d bricks:%s",
cli_req.volname, ((cli_req.type == 0)? "DEFAULT":
@@ -1148,8 +1155,11 @@ out:
" failed");
ret = 0; //Client response sent, prevent second response
}
+
gf_cmd_log ("Volume create", "on volname:%s %s", volname,
((ret || err_ret) != 0) ? "FAILED": "SUCCESS");
+ if (free_ptr)
+ GF_FREE(free_ptr);
return ret;
}
@@ -2001,6 +2011,8 @@ out:
uuid_copy (rsp.uuid, priv->uuid);
ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
gd_xdr_serialize_mgmt_friend_update_rsp);
+ if (dict)
+ dict_unref (dict);
return ret;
}
@@ -2153,8 +2165,9 @@ glusterd_friend_add (const char *hoststr, int port,
out:
gf_log ("glusterd", GF_LOG_NORMAL, "connect returned %d", ret);
+ if (rpc_cfg.remote_host)
+ GF_FREE (rpc_cfg.remote_host);
return ret;
-
}
@@ -2299,6 +2312,8 @@ glusterd_xfer_friend_remove_resp (rpcsvc_request_t *req, char *hostname, int por
ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
gd_xdr_serialize_mgmt_friend_rsp);
+ if (rsp.hostname)
+ GF_FREE (rsp.hostname);
gf_log ("glusterd", GF_LOG_NORMAL,
"Responded to %s (%d), ret: %d", hostname, port, ret);
return ret;
@@ -2686,13 +2701,15 @@ out:
if (ret) {
if (friends)
- dict_destroy (friends);
+ dict_unref (friends);
}
rsp.op_ret = ret;
ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
gf_xdr_serialize_cli_peer_list_rsp);
+ if (rsp.friends.friends_val)
+ GF_FREE (rsp.friends.friends_val);
return ret;
}
@@ -2753,7 +2770,7 @@ out:
gf_xdr_serialize_cli_peer_list_rsp);
if (volumes)
- dict_destroy (volumes);
+ dict_unref (volumes);
if (rsp.volumes.volumes_val)
GF_FREE (rsp.volumes.volumes_val);
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c
index 95fe96e04a4..1ea1fcef02e 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c
@@ -47,11 +47,13 @@ build_volfile_path (const char *volname, char *path,
glusterd_conf_t *priv = NULL;
char *vol = NULL;
char *dup_volname = NULL;
+ char *free_ptr = NULL;
char *tmp = NULL;
glusterd_volinfo_t *volinfo = NULL;
priv = THIS->private;
dup_volname = gf_strdup (volname);
+ free_ptr = dup_volname;
ret = glusterd_volinfo_find (dup_volname, &volinfo);
if (ret) {
@@ -81,9 +83,8 @@ build_volfile_path (const char *volname, char *path,
ret = 1;
out:
- if (dup_volname)
- GF_FREE (dup_volname);
-
+ if (free_ptr)
+ GF_FREE (free_ptr);
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-mem-types.h b/xlators/mgmt/glusterd/src/glusterd-mem-types.h
index 5db1e0d7915..8b99e9e4ca4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mem-types.h
+++ b/xlators/mgmt/glusterd/src/glusterd-mem-types.h
@@ -24,41 +24,41 @@
#include "mem-types.h"
enum gf_gld_mem_types_ {
- gf_gld_mt_dir_entry_t = gf_common_mt_end + 1,
- gf_gld_mt_volfile_ctx,
- gf_gld_mt_glusterd_state_t,
- gf_gld_mt_glusterd_conf_t,
- gf_gld_mt_locker,
- gf_gld_mt_string,
- gf_gld_mt_lock_table,
- gf_gld_mt_char,
- gf_gld_mt_glusterd_connection_t,
- gf_gld_mt_resolve_comp,
- gf_gld_mt_peerinfo_t,
- gf_gld_mt_friend_sm_event_t,
- gf_gld_mt_friend_req_ctx_t,
- gf_gld_mt_friend_update_ctx_t,
- gf_gld_mt_op_sm_event_t,
- gf_gld_mt_op_lock_ctx_t,
- gf_gld_mt_op_stage_ctx_t,
- gf_gld_mt_op_commit_ctx_t,
- gf_gld_mt_mop_stage_req_t,
- gf_gld_mt_probe_ctx_t,
- gf_gld_mt_create_volume_ctx_t,
- gf_gld_mt_start_volume_ctx_t,
- gf_gld_mt_stop_volume_ctx_t,
- gf_gld_mt_delete_volume_ctx_t,
- gf_gld_mt_glusterd_volinfo_t,
- gf_gld_mt_glusterd_brickinfo_t,
- gf_gld_mt_peer_hostname_t,
- gf_gld_mt_ifreq,
- gf_gld_mt_store_handle_t,
- gf_gld_mt_store_iter_t,
- gf_gld_mt_defrag_info,
- gf_gld_mt_log_filename_ctx_t,
- gf_gld_mt_log_locate_ctx_t,
- gf_gld_mt_log_rotate_ctx_t,
- gf_gld_mt_end
+ gf_gld_mt_dir_entry_t = gf_common_mt_end + 1,
+ gf_gld_mt_volfile_ctx = gf_common_mt_end + 2,
+ gf_gld_mt_glusterd_state_t = gf_common_mt_end + 3,
+ gf_gld_mt_glusterd_conf_t = gf_common_mt_end + 4,
+ gf_gld_mt_locker = gf_common_mt_end + 5,
+ gf_gld_mt_string = gf_common_mt_end + 6,
+ gf_gld_mt_lock_table = gf_common_mt_end + 7,
+ gf_gld_mt_char = gf_common_mt_end + 8,
+ gf_gld_mt_glusterd_connection_t = gf_common_mt_end + 9,
+ gf_gld_mt_resolve_comp = gf_common_mt_end + 10,
+ gf_gld_mt_peerinfo_t = gf_common_mt_end + 11,
+ gf_gld_mt_friend_sm_event_t = gf_common_mt_end + 12,
+ gf_gld_mt_friend_req_ctx_t = gf_common_mt_end + 13,
+ gf_gld_mt_friend_update_ctx_t = gf_common_mt_end + 14,
+ gf_gld_mt_op_sm_event_t = gf_common_mt_end + 15,
+ gf_gld_mt_op_lock_ctx_t = gf_common_mt_end + 16,
+ gf_gld_mt_op_stage_ctx_t = gf_common_mt_end + 17,
+ gf_gld_mt_op_commit_ctx_t = gf_common_mt_end + 18,
+ gf_gld_mt_mop_stage_req_t = gf_common_mt_end + 19,
+ gf_gld_mt_probe_ctx_t = gf_common_mt_end + 20,
+ gf_gld_mt_create_volume_ctx_t = gf_common_mt_end + 21,
+ gf_gld_mt_start_volume_ctx_t = gf_common_mt_end + 22,
+ gf_gld_mt_stop_volume_ctx_t = gf_common_mt_end + 23,
+ gf_gld_mt_delete_volume_ctx_t = gf_common_mt_end + 24,
+ gf_gld_mt_glusterd_volinfo_t = gf_common_mt_end + 25,
+ gf_gld_mt_glusterd_brickinfo_t = gf_common_mt_end + 26,
+ gf_gld_mt_peer_hostname_t = gf_common_mt_end + 27,
+ gf_gld_mt_ifreq = gf_common_mt_end + 28,
+ gf_gld_mt_store_handle_t = gf_common_mt_end + 29,
+ gf_gld_mt_store_iter_t = gf_common_mt_end + 30,
+ gf_gld_mt_defrag_info = gf_common_mt_end + 31,
+ gf_gld_mt_log_filename_ctx_t = gf_common_mt_end + 32,
+ gf_gld_mt_log_locate_ctx_t = gf_common_mt_end + 33,
+ gf_gld_mt_log_rotate_ctx_t = gf_common_mt_end + 34,
+ gf_gld_mt_end = gf_common_mt_end + 35
};
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index c78c19fdef1..57b88a72f26 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -374,7 +374,7 @@ glusterd_op_stage_create_volume (gd1_mgmt_stage_op_req *req)
ret = glusterd_brickinfo_from_brick (brick, &brick_info);
if (ret)
goto out;
- snprintf (cmd_str, 1024, "%s", brick_info->path);
+ snprintf (cmd_str, 1024, "%s", brick_info->path);
ret = glusterd_resolve_brick (brick_info);
if (ret) {
gf_log ("glusterd", GF_LOG_ERROR,
@@ -392,8 +392,11 @@ glusterd_op_stage_create_volume (gd1_mgmt_stage_op_req *req)
}
brick_list = tmpptr;
}
+ glusterd_brickinfo_delete (brick_info);
}
out:
+ if (dict)
+ dict_unref (dict);
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
@@ -585,6 +588,7 @@ glusterd_op_stage_add_brick (gd1_mgmt_stage_op_req *req)
char *bricks = NULL;
char *brick_list = NULL;
char *saveptr = NULL;
+ char *free_ptr = NULL;
char *brick = NULL;
glusterd_brickinfo_t *brickinfo = NULL;
glusterd_volinfo_t *volinfo = NULL;
@@ -629,8 +633,10 @@ glusterd_op_stage_add_brick (gd1_mgmt_stage_op_req *req)
goto out;
}
- if (bricks)
+ if (bricks) {
brick_list = gf_strdup (bricks);
+ free_ptr = brick_list;
+ }
if (count)
brick = strtok_r (brick_list+1, " \n", &saveptr);
@@ -659,11 +665,16 @@ glusterd_op_stage_add_brick (gd1_mgmt_stage_op_req *req)
goto out;
}
+ glusterd_brickinfo_delete (brickinfo);
brick = strtok_r (NULL, " \n", &saveptr);
i++;
}
out:
+ if (dict)
+ dict_unref (dict);
+ if (free_ptr)
+ GF_FREE (free_ptr);
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
@@ -751,6 +762,8 @@ glusterd_op_stage_replace_brick (gd1_mgmt_stage_op_req *req)
ret = 0;
out:
+ if (dict)
+ dict_unref (dict);
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
@@ -791,6 +804,8 @@ glusterd_op_stage_log_filename (gd1_mgmt_stage_op_req *req)
}
out:
+ if (dict)
+ dict_unref (dict);
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
@@ -896,6 +911,7 @@ glusterd_op_create_volume (gd1_mgmt_stage_op_req *req)
int32_t i = 1;
char *bricks = NULL;
char *brick_list = NULL;
+ char *free_ptr = NULL;
char *saveptr = NULL;
int32_t sub_count = 0;
@@ -976,8 +992,10 @@ glusterd_op_create_volume (gd1_mgmt_stage_op_req *req)
volinfo->sub_count = sub_count;
- if (bricks)
+ if (bricks) {
brick_list = gf_strdup (bricks);
+ free_ptr = brick_list;
+ }
if (count)
brick = strtok_r (brick_list+1, " \n", &saveptr);
@@ -1006,6 +1024,12 @@ glusterd_op_create_volume (gd1_mgmt_stage_op_req *req)
goto out;
out:
+ if (dict)
+ dict_unref (dict);
+
+ if (free_ptr)
+ GF_FREE(free_ptr);
+
return ret;
}
@@ -1024,6 +1048,8 @@ glusterd_op_add_brick (gd1_mgmt_stage_op_req *req)
int32_t i = 1;
char *bricks = NULL;
char *brick_list = NULL;
+ char *free_ptr1 = NULL;
+ char *free_ptr2 = NULL;
char *saveptr = NULL;
gf_boolean_t glfs_started = _gf_false;
int32_t mybrick = 0;
@@ -1076,8 +1102,10 @@ glusterd_op_add_brick (gd1_mgmt_stage_op_req *req)
goto out;
}
- if (bricks)
+ if (bricks) {
brick_list = gf_strdup (bricks);
+ free_ptr1 = brick_list;
+ }
if (count)
brick = strtok_r (brick_list+1, " \n", &saveptr);
@@ -1093,6 +1121,7 @@ glusterd_op_add_brick (gd1_mgmt_stage_op_req *req)
}
brick_list = gf_strdup (bricks);
+ free_ptr2 = brick_list;
i = 1;
if (count)
@@ -1149,6 +1178,12 @@ glusterd_op_add_brick (gd1_mgmt_stage_op_req *req)
out:
+ if (dict)
+ dict_unref (dict);
+ if (free_ptr1)
+ GF_FREE (free_ptr1);
+ if (free_ptr2)
+ GF_FREE (free_ptr2);
return ret;
}
@@ -1984,6 +2019,8 @@ glusterd_op_replace_brick (gd1_mgmt_stage_op_req *req)
goto out;
out:
+ if (dict)
+ dict_unref (dict);
return ret;
}
@@ -2053,7 +2090,11 @@ glusterd_op_remove_brick (gd1_mgmt_stage_op_req *req)
gf_log ("", GF_LOG_ERROR, "Unable to get %s", key);
goto out;
}
+ if (dup_brick)
+ GF_FREE (dup_brick);
dup_brick = gf_strdup (brick);
+ if (!dup_brick)
+ goto out;
ret = glusterd_brickinfo_get (dup_brick, volinfo, &brickinfo);
if (ret)
@@ -2107,6 +2148,10 @@ glusterd_op_remove_brick (gd1_mgmt_stage_op_req *req)
out:
+ if (dict)
+ dict_unref (dict);
+ if (dup_brick)
+ GF_FREE (dup_brick);
return ret;
}
@@ -3451,7 +3496,21 @@ glusterd_op_clear_ctx (glusterd_op_t op)
opinfo.op_ctx[op] = NULL;
if (ctx && glusterd_op_get_ctx_free(op)) {
- GF_FREE(ctx);
+ switch (op) {
+ case GD_OP_CREATE_VOLUME:
+ case GD_OP_STOP_VOLUME:
+ case GD_OP_ADD_BRICK:
+ case GD_OP_REMOVE_BRICK:
+ case GD_OP_REPLACE_BRICK:
+ dict_unref (ctx);
+ break;
+ case GD_OP_DELETE_VOLUME:
+ case GD_OP_START_VOLUME:
+ GF_FREE (ctx);
+ break;
+ default:
+ break;
+ }
}
return 0;
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c
index c12a11a8fb2..3eaa8ffef30 100644
--- a/xlators/mgmt/glusterd/src/glusterd-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-sm.c
@@ -153,7 +153,7 @@ glusterd_ac_friend_probe (glusterd_friend_sm_event_t *event, void *ctx)
out:
if (dict)
- dict_destroy (dict);
+ dict_unref (dict);
gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
return ret;
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 22bb1a611c1..122cb73202b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -192,6 +192,8 @@ glusterd_store_delete_brick (glusterd_volinfo_t *volinfo,
}
out:
+ if (brickinfo->shandle)
+ glusterd_store_handle_destroy (brickinfo->shandle);
gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
return ret;
}
@@ -397,6 +399,8 @@ stat_failed:
out:
+ if (volinfo->shandle)
+ glusterd_store_handle_destroy (volinfo->shandle);
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
@@ -413,6 +417,7 @@ glusterd_store_retrieve_value (glusterd_store_handle_t *handle,
char *iter_key = NULL;
char *iter_val = NULL;
char *str = NULL;
+ char *free_str = NULL;
GF_ASSERT (handle);
@@ -430,9 +435,15 @@ glusterd_store_retrieve_value (glusterd_store_handle_t *handle,
ret = fscanf (handle->read, "%s", scan_str);
while (ret != EOF) {
+ if (free_str) {
+ GF_FREE (free_str);
+ free_str = NULL;
+ }
str = gf_strdup (scan_str);
if (!str)
goto out;
+ else
+ free_str = str;
iter_key = strtok (str, "=");
gf_log ("", GF_LOG_DEBUG, "key %s read", iter_key);
@@ -456,6 +467,9 @@ out:
handle->read = NULL;
}
+ if (free_str)
+ GF_FREE (free_str);
+
return ret;
}
@@ -674,6 +688,8 @@ glusterd_retrieve_uuid ()
uuid_parse (uuid_str, priv->uuid);
out:
+ if (uuid_str)
+ GF_FREE (uuid_str);
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
@@ -730,6 +746,7 @@ glusterd_store_iter_get_next (glusterd_store_iter_t *iter,
int32_t ret = -1;
char scan_str[4096] = {0,};
char *str = NULL;
+ char *free_str = NULL;
char *iter_key = NULL;
char *iter_val = NULL;
@@ -746,6 +763,8 @@ glusterd_store_iter_get_next (glusterd_store_iter_t *iter,
str = gf_strdup (scan_str);
if (!str)
goto out;
+ else
+ free_str = str;
iter_key = strtok (str, "=");
gf_log ("", GF_LOG_DEBUG, "key %s read", iter_key);
@@ -761,8 +780,8 @@ glusterd_store_iter_get_next (glusterd_store_iter_t *iter,
ret = 0;
out:
- if (str)
- GF_FREE (str);
+ if (free_str)
+ GF_FREE (free_str);
gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
return ret;
@@ -1103,6 +1122,8 @@ glusterd_store_delete_peerinfo (glusterd_peerinfo_t *peerinfo)
ret = unlink (filepath);
out:
+ if (peerinfo->shandle)
+ glusterd_store_handle_destroy(peerinfo->shandle);
gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
return ret;
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.h b/xlators/mgmt/glusterd/src/glusterd-store.h
index 29caa899f0a..9d63fb4034f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.h
+++ b/xlators/mgmt/glusterd/src/glusterd-store.h
@@ -102,6 +102,10 @@ glusterd_store_delete_peerinfo (glusterd_peerinfo_t *peerinfo);
int32_t
glusterd_store_delete_brick (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *brickinfo);
+
+int32_t
+glusterd_store_handle_destroy (glusterd_store_handle_t *handle);
+
int32_t
glusterd_restore ();
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 1866a9904ec..0861d021913 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -661,6 +661,7 @@ glusterd_brickinfo_get (char *brick, glusterd_volinfo_t *volinfo,
char *hostname = NULL;
char *path = NULL;
char *dup_brick = NULL;
+ char *free_ptr = NULL;
glusterd_brickinfo_t *tmp = NULL;
GF_ASSERT (brick);
@@ -675,6 +676,8 @@ glusterd_brickinfo_get (char *brick, glusterd_volinfo_t *volinfo,
"Out of memory");
ret = -1;
goto out;
+ } else {
+ free_ptr = dup_brick;
}
hostname = strtok (dup_brick, ":");
@@ -701,8 +704,8 @@ glusterd_brickinfo_get (char *brick, glusterd_volinfo_t *volinfo,
*brickinfo = tmp;
out:
- if (dup_brick)
- GF_FREE (dup_brick);
+ if (free_ptr)
+ GF_FREE (free_ptr);
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
@@ -1189,7 +1192,7 @@ glusterd_build_volume_dict (dict_t **vols)
out:
gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);
if (ret)
- dict_destroy (dict);
+ dict_unref (dict);
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
index ad3eb5cc31e..3f7db7e5b5c 100644
--- a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
+++ b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
@@ -624,6 +624,8 @@ glusterd3_1_probe (call_frame_t *frame, xlator_t *this,
this, glusterd3_1_probe_cbk);
out:
+ if (req.hostname)
+ GF_FREE (req.hostname);
gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
@@ -680,7 +682,10 @@ out:
GF_FREE (req.vols.vols_val);
if (vols)
- dict_destroy (vols);
+ dict_unref (vols);
+
+ if (req.hostname)
+ GF_FREE (req.hostname);
gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
@@ -805,6 +810,10 @@ glusterd3_1_friend_update (call_frame_t *frame, xlator_t *this,
}
out:
+ if (friends)
+ dict_unref (friends);
+ if (req.friends.friends_val)
+ GF_FREE (req.friends.friends_val);
gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}