summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-self-heal-data.c
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2011-11-13 11:56:46 +0530
committerVijay Bellur <vijay@gluster.com>2011-11-23 03:11:20 -0800
commit829f2b90fba8f66287e2e3b89aed9c971c2d828b (patch)
tree9d378c333d5c21f965f36b700ead0d2d25e69804 /xlators/cluster/afr/src/afr-self-heal-data.c
parentc9fbd4c309552f7f845e73c92315abe3b6d7081b (diff)
cluster/afr: Fix memory leaks
Change-Id: I79a1c70c47649fbcf236191f174d766d5806545c BUG: 3805 Reviewed-on: http://review.gluster.com/719 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-self-heal-data.c')
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-data.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c
index 97d578c9b..fd351e976 100644
--- a/xlators/cluster/afr/src/afr-self-heal-data.c
+++ b/xlators/cluster/afr/src/afr-self-heal-data.c
@@ -805,7 +805,6 @@ afr_lookup_select_read_child_by_txn_type (xlator_t *this, afr_local_t *local,
{
afr_private_t *priv = NULL;
int read_child = -1;
- int ret = -1;
int32_t **pending_matrix = NULL;
int32_t *sources = NULL;
int32_t *success_children = NULL;
@@ -822,17 +821,13 @@ afr_lookup_select_read_child_by_txn_type (xlator_t *this, afr_local_t *local,
if (NULL == pending_matrix)
goto out;
- sources = GF_CALLOC (sizeof (*sources), priv->child_count,
- gf_afr_mt_int32_t);
- if (NULL == sources)
- goto out;
+ sources = local->cont.lookup.sources;
+ memset (sources, 0, sizeof (*sources) * priv->child_count);
nsources = afr_build_sources (this, xattr, bufs, pending_matrix,
sources, success_children, txn_type);
- if (nsources < 0) {
- ret = -1;
+ if (nsources < 0)
goto out;
- }
prev_read_child = local->read_child_index;
config_read_child = priv->read_child;
@@ -841,15 +836,10 @@ afr_lookup_select_read_child_by_txn_type (xlator_t *this, afr_local_t *local,
prev_read_child,
config_read_child,
sources);
- ret = 0;
- local->cont.lookup.sources = sources;
out:
afr_destroy_pending_matrix (pending_matrix, priv->child_count);
- if (-1 == ret) {
- if (sources)
- GF_FREE (sources);
- }
- gf_log (this->name, GF_LOG_DEBUG, "returning read_child: %d", read_child);
+ gf_log (this->name, GF_LOG_DEBUG, "returning read_child: %d",
+ read_child);
return read_child;
}