From 3b871bee4a0ad3bc8b393ba23bfcf3ad6886cf42 Mon Sep 17 00:00:00 2001 From: Anuradha Date: Tue, 23 Sep 2014 18:24:09 +0530 Subject: cluster/afr: Fixed mem leaks in self-heal code path. AFR_STACK_RESET previously didn't cleanup afr_local_t, leading to memory leaks. With this patch, cleanup is done. All credit goes to Pranith Kumar Karampuri. Change-Id: I3c727ff4bb323dccb81da4b3168ac69bb340d17d BUG: 1145471 Signed-off-by: Anuradha Reviewed-on: http://review.gluster.org/8821 Tested-by: Gluster Build System Reviewed-by: Pranith Kumar Karampuri Tested-by: Pranith Kumar Karampuri --- xlators/cluster/afr/src/afr-self-heal-data.c | 2 ++ xlators/cluster/afr/src/afr.h | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'xlators/cluster/afr/src') diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c index bee7682a23b..25e310fd2a3 100644 --- a/xlators/cluster/afr/src/afr-self-heal-data.c +++ b/xlators/cluster/afr/src/afr-self-heal-data.c @@ -176,6 +176,8 @@ __afr_selfheal_data_read_write (call_frame_t *frame, xlator_t *this, fd_t *fd, healed_sinks[i] = 0; } } + if (iovec) + GF_FREE (iovec); if (iobref) iobref_unref (iobref); diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h index cca964d9178..4b894c5c464 100644 --- a/xlators/cluster/afr/src/afr.h +++ b/xlators/cluster/afr/src/afr.h @@ -897,7 +897,21 @@ afr_cleanup_fd_ctx (xlator_t *this, fd_t *fd); frame->local = NULL; }; \ frame->local;}) -#define AFR_STACK_RESET(frame) do { int opr; STACK_RESET (frame->root); AFR_FRAME_INIT(frame, opr);} while (0) +#define AFR_STACK_RESET(frame) \ + do { \ + afr_local_t *__local = NULL; \ + xlator_t *__this = NULL; \ + __local = frame->local; \ + __this = frame->this; \ + frame->local = NULL; \ + int __opr; \ + STACK_RESET (frame->root); \ + if (__local) { \ + afr_local_cleanup (__local, __this); \ + mem_put (__local); \ + } \ + AFR_FRAME_INIT (frame, __opr); \ + } while (0) /* allocate and return a string that is the basename of argument */ static inline char * -- cgit