From 05ad7717083057de819ad545591bffeb8af2f741 Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Fri, 4 Dec 2009 04:52:33 +0000 Subject: afr: fix memory leaks Signed-off-by: Anand V. Avati Signed-off-by: Anand V. Avati BUG: 170 (Auto-heal fails on files that are open()-ed/mmap()-ed) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=170 --- xlators/cluster/afr/src/afr.c | 45 +++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'xlators/cluster/afr/src/afr.c') diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c index f81b8005da0..57af6f34225 100644 --- a/xlators/cluster/afr/src/afr.c +++ b/xlators/cluster/afr/src/afr.c @@ -289,19 +289,12 @@ afr_local_sh_cleanup (afr_local_t *local, xlator_t *this) } -void -afr_local_cleanup (afr_local_t *local, xlator_t *this) +void +afr_local_transaction_cleanup (afr_local_t *local, xlator_t *this) { - int i; + int i = 0; afr_private_t * priv = NULL; - if (!local) - return; - - afr_local_sh_cleanup (local, this); - - FREE (local->child_errno); - priv = this->private; for (i = 0; i < priv->child_count; i++) { @@ -311,17 +304,35 @@ afr_local_cleanup (afr_local_t *local, xlator_t *this) FREE (local->pending); - loc_wipe (&local->loc); - loc_wipe (&local->newloc); - FREE (local->transaction.locked_nodes); FREE (local->transaction.child_errno); + FREE (local->child_errno); FREE (local->transaction.basename); FREE (local->transaction.new_basename); - loc_wipe (&local->transaction.parent_loc); + loc_wipe (&local->transaction.parent_loc); loc_wipe (&local->transaction.new_parent_loc); +} + + +void +afr_local_cleanup (afr_local_t *local, xlator_t *this) +{ + int i; + afr_private_t * priv = NULL; + + if (!local) + return; + + afr_local_sh_cleanup (local, this); + + afr_local_transaction_cleanup (local, this); + + priv = this->private; + + loc_wipe (&local->loc); + loc_wipe (&local->newloc); if (local->fd) fd_unref (local->fd); @@ -1422,6 +1433,12 @@ afr_release (xlator_t *this, fd_t *fd) if (fd_ctx->child_failed) FREE (fd_ctx->child_failed); + if (fd_ctx->pre_op_done) + FREE (fd_ctx->pre_op_done); + + if (fd_ctx->opened_on) + FREE (fd_ctx->opened_on); + FREE (fd_ctx); } -- cgit