summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-common.c
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2014-08-27 15:14:04 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2014-08-28 01:19:24 -0700
commitdc844c545caa7f2cf08fd71caa5051348a5f3c78 (patch)
treefcb79d0c2d36d9846729199bbbe95cf0e924867d /xlators/cluster/afr/src/afr-common.c
parent92d1ae829ce5dfca7af2fdb33f10305732028602 (diff)
cluster/afr: Fix dict_t leaks
dict_t objects that are ref'd in alloca'd "replies" in afr_replies_copy() are not unref'd after "replies" go out of scope. Change-Id: Id5a6ca3c17a8de72b94b3e0f92165609da5a36ea BUG: 1134221 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> Reviewed-on: http://review.gluster.org/8553 Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-common.c')
-rw-r--r--xlators/cluster/afr/src/afr-common.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index cc7df9a3ea6..8ab67af405f 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -472,7 +472,7 @@ afr_refresh_selfheal_wrap (void *opaque)
err = afr_inode_refresh_err (frame, this);
- afr_replies_wipe (local, this->private);
+ afr_local_replies_wipe (local, this->private);
local->refreshfn (frame, this, err);
@@ -509,7 +509,7 @@ afr_inode_refresh_done (call_frame_t *frame, xlator_t *this)
err = afr_inode_refresh_err (frame, this);
- afr_replies_wipe (local, this->private);
+ afr_local_replies_wipe (local, this->private);
if (ret && afr_selfheal_enabled (this)) {
heal = copy_frame (frame);
@@ -588,7 +588,7 @@ afr_inode_refresh_do (call_frame_t *frame, xlator_t *this)
priv = this->private;
local = frame->local;
- afr_replies_wipe (local, priv);
+ afr_local_replies_wipe (local, priv);
xdata = dict_new ();
if (!xdata) {
@@ -877,19 +877,26 @@ afr_local_transaction_cleanup (afr_local_t *local, xlator_t *this)
void
-afr_replies_wipe (afr_local_t *local, afr_private_t *priv)
+afr_replies_wipe (struct afr_reply *replies, int count)
+{
+ int i = 0;
+
+ for (i = 0; i < count; i++) {
+ if (replies[i].xdata) {
+ dict_unref (replies[i].xdata);
+ replies[i].xdata = NULL;
+ }
+ }
+}
+
+void
+afr_local_replies_wipe (afr_local_t *local, afr_private_t *priv)
{
- int i;
if (!local->replies)
return;
- for (i = 0; i < priv->child_count; i++) {
- if (local->replies[i].xdata) {
- dict_unref (local->replies[i].xdata);
- local->replies[i].xdata = NULL;
- }
- }
+ afr_replies_wipe (local->replies, priv->child_count);
memset (local->replies, 0, sizeof(*local->replies) * priv->child_count);
}
@@ -934,7 +941,7 @@ afr_local_cleanup (afr_local_t *local, xlator_t *this)
if (local->dict)
dict_unref (local->dict);
- afr_replies_wipe (local, priv);
+ afr_local_replies_wipe (local, priv);
GF_FREE(local->replies);
GF_FREE (local->child_up);
@@ -1446,7 +1453,7 @@ afr_lookup_selfheal_wrap (void *opaque)
afr_selfheal_name (frame->this, local->loc.pargfid, local->loc.name,
&local->cont.lookup.gfid_req);
- afr_replies_wipe (local, this->private);
+ afr_local_replies_wipe (local, this->private);
inode = afr_selfheal_unlocked_lookup_on (frame, local->loc.parent,
local->loc.name, local->replies,