[PATCH 09/11] votequorum: free our data and lists on exit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Fabio M. Di Nitto" <fdinitto@xxxxxxxxxx>

this is mostly to avoid valgrind errors on exit and make the output
more readable.

Signed-off-by: Fabio M. Di Nitto <fdinitto@xxxxxxxxxx>
---
 exec/votequorum.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/exec/votequorum.c b/exec/votequorum.c
index eda6daa..9209bdd 100644
--- a/exec/votequorum.c
+++ b/exec/votequorum.c
@@ -1668,14 +1668,57 @@ static void message_handler_req_exec_votequorum_reconfigure (
 static int votequorum_exec_exit_fn (void)
 {
 	int ret = 0;
+	struct cluster_node *node;
+	struct quorum_pd *qpd;
+	struct list_head *tmp;
 
 	ENTER();
 
+	/*
+	 * tell the other nodes we are leaving
+	 */
+
 	if (leave_remove) {
 		us->flags |= NODE_FLAGS_LEAVING;
 		ret = votequorum_exec_send_nodeinfo(us->node_id);
 	}
 
+	/*
+	 * clean up our internals
+	 */
+
+	/*
+	 * free the node list and qdevice
+	 */
+
+	if (qdevice) {
+		free(qdevice);
+		qdevice = NULL;
+	}
+
+	list_iterate(tmp, &cluster_members_list) {
+		node = list_entry(tmp, struct cluster_node, list);
+		if (node) {
+			list_del(tmp);
+			free(node);
+			node = NULL;
+		}
+	}
+
+	us = NULL;
+
+	/*
+	 * clean the tracking list
+	 * should we notify that service is going away?
+	 */
+
+	list_iterate(tmp, &trackers_list) {
+		qpd = list_entry(tmp, struct quorum_pd, list);
+		if (qpd) {
+			list_del(tmp);
+		}
+	}
+
 	LEAVE();
 	return ret;
 }
-- 
1.7.7.6

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss


[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux