summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGaurav Kumar Garg <garg.gaurav52@gmail.com>2015-12-09 20:12:17 +0530
committerJeff Darcy <jdarcy@redhat.com>2016-02-23 20:19:05 -0800
commite38bf1bdeda3c7a89be3193ad62a72b9139358dd (patch)
tree76bbbb4d708c3947f05434cfd7a91651cede960b
parent8cf29a4207c162be8e2993ae36f49090851cbbfc (diff)
glusterd: fixing few memory leak in glusterd
Current glusterd code base having memory leak. This is because of memory allocate by dict_allocate_and_serialize function in "gd_syncop_mgmt_v3_lock" and "gd_syncop_mgmt_v3_unlock" function is not freeing up meory upon exit. Fix is to free the memory after exit of the above function. Thanx Carlos and Roman for finding out the issue and fix. Change-Id: Id67aa794c84969830ca7ea8c2374f80c64d7a639 BUG: 1287517 Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com> Signed-off-by: Carlos Chinea <carlos.chinea@nokia.com> Signed-off-by: Roman Tereshonkov <roman.tereshonkov@nokia.com> Reviewed-on: http://review.gluster.org/12927 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
-rw-r--r--glusterfsd/src/glusterfsd.c3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handshake.c3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rpc-ops.c11
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-sm.c9
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-syncop.c4
6 files changed, 28 insertions, 4 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index c980e7bc640..4edb5894c60 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -2196,14 +2196,12 @@ glusterfs_process_volfp (glusterfs_ctx_t *ctx, FILE *fp)
ret = glusterfs_graph_prepare (graph, ctx);
if (ret) {
- glusterfs_graph_destroy (graph);
goto out;
}
ret = glusterfs_graph_activate (graph, ctx);
if (ret) {
- glusterfs_graph_destroy (graph);
goto out;
}
@@ -2215,6 +2213,7 @@ out:
fclose (fp);
if (ret && !ctx->active) {
+ glusterfs_graph_destroy (graph);
/* there is some error in setting up the first graph itself */
cleanup_and_exit (0);
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c
index 756e48965c2..b53e0968398 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c
@@ -2201,5 +2201,8 @@ glusterd_peer_dump_version (xlator_t *this, struct rpc_clnt *rpc,
unlock:
rcu_read_unlock ();
out:
+ if (ret && frame)
+ STACK_DESTROY (frame->root);
+
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
index e670c98a7c9..e50158e11a7 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
@@ -532,6 +532,7 @@ out:
glusterd_friend_sm ();
glusterd_op_sm ();
}
+
if (ctx)
glusterd_destroy_probe_ctx (ctx);
free (rsp.hostname);//malloced by xdr
@@ -1715,6 +1716,9 @@ glusterd_rpc_friend_update (call_frame_t *frame, xlator_t *this,
out:
GF_FREE (req.friends.friends_val);
+ if (ret && dummy_frame)
+ STACK_DESTROY (frame->root);
+
gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -1750,6 +1754,9 @@ glusterd_cluster_lock (call_frame_t *frame, xlator_t *this,
(xdrproc_t)xdr_gd1_mgmt_cluster_lock_req);
out:
gf_msg_debug ("glusterd", 0, "Returning %d", ret);
+
+ if (ret && dummy_frame)
+ STACK_DESTROY (frame->root);
return ret;
}
@@ -1936,6 +1943,10 @@ glusterd_cluster_unlock (call_frame_t *frame, xlator_t *this,
(xdrproc_t)xdr_gd1_mgmt_cluster_unlock_req);
out:
gf_msg_debug (this ? this->name : "glusterd", 0, "Returning %d", ret);
+
+ if (ret && dummy_frame)
+ STACK_DESTROY (frame->root);
+
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c
index 791405dc40e..ea8cdc29794 100644
--- a/xlators/mgmt/glusterd/src/glusterd-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-sm.c
@@ -327,6 +327,9 @@ glusterd_ac_friend_add (glusterd_friend_sm_event_t *event, void *ctx)
out:
rcu_read_unlock ();
+ if (ret && frame)
+ STACK_DESTROY (frame->root);
+
gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
return ret;
}
@@ -408,6 +411,9 @@ out:
dict_unref (dict);
gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
+ if (ret && frame)
+ STACK_DESTROY (frame->root);
+
return ret;
}
@@ -486,6 +492,9 @@ out:
gf_msg_debug ("glusterd", 0, "Returning with %d", ret);
+ if (ret && frame)
+ STACK_DESTROY (frame->root);
+
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 5f04f7cdffd..c17a2e10a83 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -4001,7 +4001,6 @@ glusterd_store_retrieve_peers (xlator_t *this)
struct dirent *entry = NULL;
char path[PATH_MAX] = {0,};
glusterd_peerinfo_t *peerinfo = NULL;
- char *hostname = NULL;
gf_store_handle_t *shandle = NULL;
char filepath[PATH_MAX] = {0,};
gf_store_iter_t *iter = NULL;
@@ -4084,7 +4083,6 @@ glusterd_store_retrieve_peers (xlator_t *this)
&op_errno);
}
if (op_errno != GD_STORE_EOF) {
- GF_FREE(hostname);
goto out;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c
index ac4870d516c..bb385d4775d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c
+++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c
@@ -215,6 +215,8 @@ out:
iobref_unref (iobref);
iobuf_unref (iobuf);
+ if (ret && frame)
+ STACK_DESTROY (frame->root);
return ret;
}
@@ -411,6 +413,7 @@ gd_syncop_mgmt_v3_lock (glusterd_op_t op, dict_t *op_ctx,
(xdrproc_t)
xdr_gd1_mgmt_v3_lock_req);
out:
+ GF_FREE (req.dict.dict_val);
gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}
@@ -510,6 +513,7 @@ gd_syncop_mgmt_v3_unlock (dict_t *op_ctx, glusterd_peerinfo_t *peerinfo,
(xdrproc_t)
xdr_gd1_mgmt_v3_unlock_req);
out:
+ GF_FREE (req.dict.dict_val);
gf_msg_debug ("glusterd", 0, "Returning %d", ret);
return ret;
}