From 6302f2c2262647974e94b494805f2a70da142949 Mon Sep 17 00:00:00 2001 From: Pavan Sondur Date: Mon, 25 Jan 2010 05:50:38 +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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c index 68090953b..4a2c675f7 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -52,6 +52,8 @@ struct quota_priv { uint32_t current_free_disk; /* current free disk space available, in % */ uint32_t refresh_interval; /* interval in seconds */ uint32_t min_disk_last_updated_time; /* used for interval calculation */ + + dict_t *dict; /* dictionary pointer used while syncing disk usage */ }; @@ -788,12 +790,17 @@ int quota_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno) { + struct quota_priv *priv = NULL; + + priv = this->private; + if (op_ret == -1) { gf_log (this->name, GF_LOG_CRITICAL, "failed to set the disk-usage value: %s", strerror (op_errno)); } + dict_unref (priv->dict); STACK_DESTROY (frame->root); return 0; } @@ -905,6 +912,9 @@ gf_quota_cache_sync (xlator_t *this) dict_set (dict, "trusted.glusterfs-quota-du", data_from_uint64 (priv->current_disk_usage)); + dict_ref (dict); + priv->dict = dict; + STACK_WIND (frame, quota_setxattr_cbk, this->children->xlator, this->children->xlator->fops->setxattr, -- cgit