[corosync] [PATCH 6/7] OBJDB: free up resources on exit

Angus Salkeld asalkeld at redhat.com
Thu Nov 10 10:54:55 GMT 2011


Signed-off-by: Angus Salkeld <asalkeld at redhat.com>
---
 exec/main.c                     |    5 +++++
 exec/objdb.c                    |   16 +++++++++++++---
 include/corosync/engine/objdb.h |    1 +
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/exec/main.c b/exec/main.c
index 957634e..a76828b 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -1648,6 +1648,11 @@ int main (int argc, char **argv, char **envp)
 	 */
 	qb_loop_destroy (corosync_poll_handle);
 
+	/*
+	 * free up the objdb
+	 */
+	objdb->objdb_fini ();
+
 	logsys_system_fini ();
 
 	/*
diff --git a/exec/objdb.c b/exec/objdb.c
index 999db61..37a521a 100644
--- a/exec/objdb.c
+++ b/exec/objdb.c
@@ -104,6 +104,8 @@ struct object_find_instance {
 struct objdb_iface_ver0 objdb_iface;
 struct list_head objdb_trackers_head;
 
+static int object_destroy (hdb_handle_t object_handle);
+
 DECLARE_HDB_DATABASE (object_instance_database,NULL);
 
 DECLARE_HDB_DATABASE (object_find_instance_database,NULL);
@@ -125,7 +127,7 @@ static int objdb_init (void)
 		goto error_destroy;
 	}
 	instance->find_child_list = &instance->child_head;
-	instance->object_name = (char *)"parent";
+	instance->object_name = strdup("parent");
 	instance->object_name_len = strlen ("parent");
 	instance->object_handle = handle;
 	instance->parent_handle = OBJECT_PARENT_HANDLE;
@@ -148,6 +150,13 @@ error_exit:
 	return (-1);
 }
 
+
+static void objdb_fini (void)
+{
+	object_destroy (OBJECT_PARENT_HANDLE);
+	hdb_destroy (&object_instance_database);
+}
+
 static int _object_notify_deleted_children(struct object_instance *parent_pt)
 {
 	struct list_head *list;
@@ -1810,8 +1819,9 @@ struct objdb_iface_ver0 objdb_iface = {
 	.object_key_increment   = object_key_increment,
 	.object_key_decrement   = object_key_decrement,
 	.object_key_create_typed	= object_key_create_typed,
-	.object_key_get_typed		= object_key_get_typed,
-	.object_key_iter_typed		= object_key_iter_typed,
+	.object_key_get_typed	= object_key_get_typed,
+	.object_key_iter_typed	= object_key_iter_typed,
+	.objdb_fini		= objdb_fini,
 };
 
 struct lcr_iface objdb_iface_ver0[1] = {
diff --git a/include/corosync/engine/objdb.h b/include/corosync/engine/objdb.h
index 14b12d4..d6d46db 100644
--- a/include/corosync/engine/objdb.h
+++ b/include/corosync/engine/objdb.h
@@ -269,6 +269,7 @@ struct objdb_iface_ver0 {
 		void **value,
 		size_t *value_len,
 		objdb_value_types_t *type);
+	void (*objdb_fini) (void);
 };
 
 #endif /* OBJDB_H_DEFINED */
-- 
1.7.7



More information about the discuss mailing list