summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorVikas Gorur <vikas@gluster.com>2009-09-24 04:18:18 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-09-24 07:13:37 -0700
commit5816d5dcc5e564017c101acb65e496a8d631b4eb (patch)
tree911577ee213ba5841c8e17e774c3ceb67fe83465 /xlators/cluster
parent2317913ae5556fe402828d97f7da761124c15ba2 (diff)
cluster/afr: Fix memory leak in "diff" self-heal algorithm.
FREE sh->private after diff self-heal is done. Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 281 (memory leak in "diff" self heal algorithm) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=281
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-algorithm.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-algorithm.c b/xlators/cluster/afr/src/afr-self-heal-algorithm.c
index f6efcfa66..46d451913 100644
--- a/xlators/cluster/afr/src/afr-self-heal-algorithm.c
+++ b/xlators/cluster/afr/src/afr-self-heal-algorithm.c
@@ -234,6 +234,32 @@ afr_sh_algo_full (call_frame_t *frame, xlator_t *this)
*/
+static void
+sh_diff_private_cleanup (call_frame_t *frame, xlator_t *this)
+{
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
+ afr_self_heal_t * sh = NULL;
+ afr_sh_algo_diff_private_t *sh_priv = NULL;
+
+ priv = this->private;
+ local = frame->local;
+ sh = &local->self_heal;
+
+ sh_priv = sh->private;
+
+ if (sh_priv) {
+ if (sh_priv->checksum)
+ FREE (sh_priv->checksum);
+
+ if (sh_priv->write_needed)
+ FREE (sh_priv->write_needed);
+
+ FREE (sh_priv);
+ }
+}
+
+
static int
sh_diff_number_of_writes_needed (unsigned char *write_needed, int child_count)
{
@@ -530,6 +556,8 @@ sh_diff_iter (call_frame_t *frame, xlator_t *this)
sh = &local->self_heal;
if (sh->op_failed) {
+ sh_diff_private_cleanup (frame, this);
+
local->self_heal.algo_abort_cbk (frame, this);
goto out;
}
@@ -539,6 +567,8 @@ sh_diff_iter (call_frame_t *frame, xlator_t *this)
"closing fd's of %s",
local->loc.path);
+ sh_diff_private_cleanup (frame, this);
+
local->self_heal.algo_completion_cbk (frame, this);
goto out;