From ec7277113956520fa6637c94d60d13d398617225 Mon Sep 17 00:00:00 2001 From: Pavan Sondur Date: Mon, 22 Feb 2010 05:00:01 +0000 Subject: features/quota: Fix memory leak while syncing disk usage. Signed-off-by: Pavan Vilas Sondur Signed-off-by: Anand V. Avati BUG: 569 (Memory leak in quota translator) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=569 --- xlators/features/quota/src/quota.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'xlators') diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c index 3d75f6add3c..41d8b24f96b 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -797,12 +797,19 @@ int quota_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno) { + dict_t *dict = NULL; + if (op_ret == -1) { gf_log (this->name, GF_LOG_CRITICAL, "failed to set the disk-usage value: %s", strerror (op_errno)); } + if (cookie) { + dict = (dict_t *) cookie; + dict_unref (dict); + } + STACK_DESTROY (frame->root); return 0; } @@ -914,10 +921,13 @@ gf_quota_cache_sync (xlator_t *this) dict_set (dict, "trusted.glusterfs-quota-du", data_from_uint64 (priv->current_disk_usage)); - STACK_WIND (frame, quota_setxattr_cbk, - this->children->xlator, - this->children->xlator->fops->setxattr, - &loc, dict, 0); + dict_ref (dict); + + STACK_WIND_COOKIE (frame, quota_setxattr_cbk, + (void *) (dict_t *) dict, + this->children->xlator, + this->children->xlator->fops->setxattr, + &loc, dict, 0); } -- cgit