Browse Source

votequorum: free our data and lists on exit

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

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Fabio M. Di Nitto 14 years ago
parent
commit
861d2c90ef
1 changed files with 43 additions and 0 deletions
  1. 43 0
      exec/votequorum.c

+ 43 - 0
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;
 }