summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand Avati <avati@gluster.com>2009-12-04 04:52:33 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-12-04 02:52:00 -0800
commit05ad7717083057de819ad545591bffeb8af2f741 (patch)
treea6218ced4773af8b6d02940688ccb2ec9391a5c3
parent349f9b77178aac3d2823bb35b0dc6c40b7a3b876 (diff)
afr: fix memory leaks
Signed-off-by: Anand V. Avati <avati@blackhole.gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> 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
-rw-r--r--xlators/cluster/afr/src/afr-open.c2
-rw-r--r--xlators/cluster/afr/src/afr.c45
-rw-r--r--xlators/cluster/afr/src/afr.h3
3 files changed, 36 insertions, 14 deletions
diff --git a/xlators/cluster/afr/src/afr-open.c b/xlators/cluster/afr/src/afr-open.c
index e60ec70c0c4..ae58eef0616 100644
--- a/xlators/cluster/afr/src/afr-open.c
+++ b/xlators/cluster/afr/src/afr-open.c
@@ -430,6 +430,8 @@ afr_up_down_flush_done (call_frame_t *frame, xlator_t *this)
out:
UNLOCK (&local->fd->lock);
+ afr_local_transaction_cleanup (local, this);
+
local->up_down_flush_cbk (frame, this);
return 0;
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);
}
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index c5db12a445c..71f4b7e561e 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -621,6 +621,9 @@ afr_set_opendir_done (xlator_t *this, inode_t *inode);
uint64_t
afr_is_opendir_done (xlator_t *this, inode_t *inode);
+void
+afr_local_transaction_cleanup (afr_local_t *local, xlator_t *this);
+
#define AFR_STACK_UNWIND(fop, frame, params ...) \
do { \
afr_local_t *__local = NULL; \