summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-sm.c
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2010-09-02 07:06:47 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-02 06:31:41 -0700
commitee7f340f73eb2b61d5d1f6b881eede3b39432c9f (patch)
treedea647e1a9cba2e1a681befee9ad5ae6675c19ce /xlators/mgmt/glusterd/src/glusterd-sm.c
parent0d1199ecf08cb513db7bcd26db672811207fe5cf (diff)
mgmt/glusterd: memory leak fixes
Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1186 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1186
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-sm.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-sm.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c
index 3eaa8ffef30..2be2de4d203 100644
--- a/xlators/mgmt/glusterd/src/glusterd-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-sm.c
@@ -46,6 +46,33 @@
static struct list_head gd_friend_sm_queue;
+void
+glusterd_destroy_probe_ctx (glusterd_probe_ctx_t *ctx)
+{
+ if (!ctx)
+ return;
+
+ if (ctx->hostname)
+ GF_FREE (ctx->hostname);
+ GF_FREE (ctx);
+}
+
+void
+glusterd_destroy_friend_req_ctx (glusterd_friend_req_ctx_t *ctx)
+{
+ if (!ctx)
+ return;
+
+ if (ctx->vols)
+ dict_unref (ctx->vols);
+ if (ctx->hostname)
+ GF_FREE (ctx->hostname);
+ GF_FREE (ctx);
+}
+
+#define glusterd_destroy_friend_update_ctx(ctx)\
+ glusterd_destroy_friend_req_ctx(ctx)
+
static int
glusterd_ac_none (glusterd_friend_sm_event_t *event, void *ctx)
{
@@ -543,6 +570,27 @@ glusterd_friend_sm_inject_event (glusterd_friend_sm_event_t *event)
return 0;
}
+void
+glusterd_destroy_friend_event_context (glusterd_friend_sm_event_t *event)
+{
+ if (!event)
+ return;
+
+ switch (event->event) {
+ case GD_FRIEND_EVENT_RCVD_FRIEND_REQ:
+ case GD_FRIEND_EVENT_RCVD_REMOVE_FRIEND:
+ glusterd_destroy_friend_req_ctx (event->ctx);
+ break;
+ case GD_FRIEND_EVENT_LOCAL_ACC:
+ case GD_FRIEND_EVENT_LOCAL_RJT:
+ case GD_FRIEND_EVENT_RCVD_ACC:
+ case GD_FRIEND_EVENT_RCVD_RJT:
+ glusterd_destroy_friend_update_ctx(event->ctx);
+ break;
+ default:
+ break;
+ }
+}
int
glusterd_friend_sm ()
@@ -594,12 +642,14 @@ glusterd_friend_sm ()
if (ret) {
gf_log ("glusterd", GF_LOG_ERROR, "handler returned: "
"%d", ret);
+ glusterd_destroy_friend_event_context (event);
GF_FREE (event);
continue;
}
if ((GD_FRIEND_EVENT_REMOVE_FRIEND == event_type) ||
(GD_FRIEND_EVENT_INIT_REMOVE_FRIEND == event_type)){
+ glusterd_destroy_friend_event_context (event);
GF_FREE (event);
continue;
}
@@ -615,6 +665,7 @@ glusterd_friend_sm ()
ret = glusterd_store_update_peerinfo (peerinfo);
+ glusterd_destroy_friend_event_context (event);
GF_FREE (event);
}
}