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>
This commit is contained in:
parent
c9fbd4c309
commit
829f2b90fb
@ -1057,6 +1057,7 @@ afr_lookup_build_response_params (afr_local_t *local, xlator_t *this)
|
|||||||
}
|
}
|
||||||
gf_log (this->name, GF_LOG_DEBUG, "Building lookup response from %d",
|
gf_log (this->name, GF_LOG_DEBUG, "Building lookup response from %d",
|
||||||
read_child);
|
read_child);
|
||||||
|
if (!*xattr)
|
||||||
*xattr = dict_ref (local->cont.lookup.xattrs[read_child]);
|
*xattr = dict_ref (local->cont.lookup.xattrs[read_child]);
|
||||||
*buf = local->cont.lookup.bufs[read_child];
|
*buf = local->cont.lookup.bufs[read_child];
|
||||||
*postparent = local->cont.lookup.postparents[read_child];
|
*postparent = local->cont.lookup.postparents[read_child];
|
||||||
@ -1920,6 +1921,7 @@ afr_lookup_cont_init (afr_local_t *local, unsigned int child_count)
|
|||||||
int ret = -ENOMEM;
|
int ret = -ENOMEM;
|
||||||
struct iatt *iatts = NULL;
|
struct iatt *iatts = NULL;
|
||||||
int32_t *success_children = NULL;
|
int32_t *success_children = NULL;
|
||||||
|
int32_t *sources = NULL;
|
||||||
|
|
||||||
GF_ASSERT (local);
|
GF_ASSERT (local);
|
||||||
local->cont.lookup.xattrs = GF_CALLOC (child_count,
|
local->cont.lookup.xattrs = GF_CALLOC (child_count,
|
||||||
@ -1947,6 +1949,11 @@ afr_lookup_cont_init (afr_local_t *local, unsigned int child_count)
|
|||||||
if (NULL == local->fresh_children)
|
if (NULL == local->fresh_children)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
sources = GF_CALLOC (sizeof (*sources), child_count, gf_afr_mt_int32_t);
|
||||||
|
if (NULL == sources)
|
||||||
|
goto out;
|
||||||
|
local->cont.lookup.sources = sources;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
out:
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -805,7 +805,6 @@ afr_lookup_select_read_child_by_txn_type (xlator_t *this, afr_local_t *local,
|
|||||||
{
|
{
|
||||||
afr_private_t *priv = NULL;
|
afr_private_t *priv = NULL;
|
||||||
int read_child = -1;
|
int read_child = -1;
|
||||||
int ret = -1;
|
|
||||||
int32_t **pending_matrix = NULL;
|
int32_t **pending_matrix = NULL;
|
||||||
int32_t *sources = NULL;
|
int32_t *sources = NULL;
|
||||||
int32_t *success_children = 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)
|
if (NULL == pending_matrix)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
sources = GF_CALLOC (sizeof (*sources), priv->child_count,
|
sources = local->cont.lookup.sources;
|
||||||
gf_afr_mt_int32_t);
|
memset (sources, 0, sizeof (*sources) * priv->child_count);
|
||||||
if (NULL == sources)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
nsources = afr_build_sources (this, xattr, bufs, pending_matrix,
|
nsources = afr_build_sources (this, xattr, bufs, pending_matrix,
|
||||||
sources, success_children, txn_type);
|
sources, success_children, txn_type);
|
||||||
if (nsources < 0) {
|
if (nsources < 0)
|
||||||
ret = -1;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
prev_read_child = local->read_child_index;
|
prev_read_child = local->read_child_index;
|
||||||
config_read_child = priv->read_child;
|
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,
|
prev_read_child,
|
||||||
config_read_child,
|
config_read_child,
|
||||||
sources);
|
sources);
|
||||||
ret = 0;
|
|
||||||
local->cont.lookup.sources = sources;
|
|
||||||
out:
|
out:
|
||||||
afr_destroy_pending_matrix (pending_matrix, priv->child_count);
|
afr_destroy_pending_matrix (pending_matrix, priv->child_count);
|
||||||
if (-1 == ret) {
|
gf_log (this->name, GF_LOG_DEBUG, "returning read_child: %d",
|
||||||
if (sources)
|
read_child);
|
||||||
GF_FREE (sources);
|
|
||||||
}
|
|
||||||
gf_log (this->name, GF_LOG_DEBUG, "returning read_child: %d", read_child);
|
|
||||||
return read_child;
|
return read_child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user