From 5816d5dcc5e564017c101acb65e496a8d631b4eb Mon Sep 17 00:00:00 2001 From: Vikas Gorur Date: Thu, 24 Sep 2009 04:18:18 +0000 Subject: 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 BUG: 281 (memory leak in "diff" self heal algorithm) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=281 --- xlators/cluster/afr/src/afr-self-heal-algorithm.c | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'xlators/cluster') diff --git a/xlators/cluster/afr/src/afr-self-heal-algorithm.c b/xlators/cluster/afr/src/afr-self-heal-algorithm.c index f6efcfa6605..46d451913b0 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; -- cgit