[Openais] [PATCH] corosync/trunk: fix config load order in objdb

Fabio M. Di Nitto fabbione at fabbione.net
Mon Aug 11 23:46:12 PDT 2008


Hi Steven,

new patch in attachment:

- change list_add to list_add_tail
- fix unloading of services to respect original behaviour
   (last loaded, first unloaded)
- few whitespace cleanups

Fabio

On Mon, 11 Aug 2008, Steven Dake wrote:

> I don't have a problem with this patch but it breaks shutdown.
>
> Example:
>
> Before patch (pressing ctrl-c)
> Aug 11  8:21:18.601215 [SERV ] Unloading openais component:
> corosync_confdb v0
> Aug 11  8:21:18.601259 [SERV ] Unloading openais component: corosync_cpg
> v0
> Aug 11  8:21:18.601287 [SERV ] Unloading openais component: corosync_cfg
> v0
> Aug 11  8:21:18.601314 [SERV ] Unloading openais component: corosync_evs
> v0
> A
> After patch (pressing ctrl-c)
> Aug 11  8:19:20.983285 [TOTEM] entering OPERATIONAL state.
> Aug 11  8:19:23.045472 [SERV ] Unloading all openais components
> Aug 11  8:19:23.045550 [SERV ] Unloading openais component: corosync_evs
> v0
> Aug 11  8:19:23.050464 [SERV ] Unloading openais component: corosync_cfg
> v0
> Aug 11  8:19:23.050516 [SERV ] Unloading openais component: corosync_cpg
> v0
> Aug 11  8:19:23.050544 [SERV ] Unloading openais component:
> corosync_confdb v0
> Aug 11  8:19:23.050754 [MAIN ] AIS Executive exiting with status -1 at
> main.c:151.
>
> The original behavior must be retained in the unloading of all the
> modules, that is, The last loaded module should be unloaded first or it
> will break other services possibly pacemaker.
>
> regards
> -steve
>
> On Mon, 2008-08-11 at 17:01 +0200, Fabio M. Di Nitto wrote:
>> Hi guys,
>>
>> there is a substantial problem in the way keys and objectes are created
>> within the objdb.
>>
>> Let's assume this config file:
>>
>> <foo>
>>   <bar name="1" action="off"/>
>>   <bar name="2" action="on"/>
>> </foo>
>>
>> (very similar to our fence method configuration snippet)
>>
>> Using list_add to create the keys and objects, the configuration in the
>> object db is mirrored:
>>
>> <foo>
>>   <bar action="on" name="2"/>
>>   <bar action="off" name="1"/>
>> </foo>
>>
>> the patch in attachment change list_add into list_add_tail to insert data
>> in the objdb in the same order as they have been pushed.
>>
>> While _generally_ this shouldn't be an issue, we have services like fence,
>> that relies on the correct order of data to be returned from the objdb in
>> order to perform their operations correctly.
>>
>> Please apply
>>
>> Fabio
>>
>> --
>> I'm going to make him an offer he can't refuse.
>> _______________________________________________ Openais mailing list Openais at lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/openais
>


--
I'm going to make him an offer he can't refuse.
-------------- next part --------------
Index: exec/service.c
===================================================================
--- exec/service.c	(revision 1626)
+++ exec/service.c	(working copy)
@@ -266,7 +266,7 @@
 			strlen ("ver"),
 			(void *)&found_service_ver,
 			NULL);
-				
+
 		/*
 		 * If service found and linked exit it
 		 */
@@ -294,34 +294,32 @@
 	unsigned int *service_ver;
 	unsigned int object_service_handle;
 	unsigned int object_find_handle;
-	unsigned int res;
+	int found; 
 
 	log_printf(LOG_LEVEL_NOTICE, "Unloading all openais components\n");
-	
-	res = 0;
+
 	/*
 	 * TODO
 	 * Deleting of keys not supported during iteration at this time
 	 * hence this ugly hack
 	 */
-	for (;;) {
-		corosync_api->object_find_create (
+	while(corosync_api->object_find_create (
 			object_internal_configuration_handle,
 			"service",
 			strlen ("service"),
-			&object_find_handle);
+			&object_find_handle) == 0)
+	{
 
-		res = corosync_api->object_find_next (
+		found = 0;
+
+		while(corosync_api->object_find_next (
 			object_find_handle,
-			&object_service_handle);
+			&object_service_handle) == 0)
+			found = 1;
 
-		/*
-		 * Exit from unloading
-		 */
-		if (res == -1) {
+		if(!found)
 			break;
-		}
-			
+
 		corosync_api->object_key_get (
 			object_service_handle,
 			"name",
@@ -335,7 +333,7 @@
 			strlen ("ver"),
 			(void *)&service_ver,
 			NULL);
-					
+
 		openais_service_unlink_common (
 			corosync_api, object_service_handle,
 			service_name, *service_ver);
Index: exec/objdb.c
===================================================================
--- exec/objdb.c	(revision 1626)
+++ exec/objdb.c	(working copy)
@@ -360,7 +360,7 @@
 
 	object_instance->object_name_len = object_name_len;
 
-	list_add (&object_instance->child_list, &parent_instance->child_head);
+	list_add_tail (&object_instance->child_list, &parent_instance->child_head);
 
 	object_instance->object_handle = *object_handle;
 	object_instance->find_child_list = &object_instance->child_head;
@@ -488,7 +488,7 @@
 	object_key->value_len = value_len;
 
 	list_init (&object_key->list);
-	list_add (&object_key->list, &instance->key_head);
+	list_add_tail (&object_key->list, &instance->key_head);
 	object_key_changed_notification(object_handle, key_name, key_len,
 								value, value_len, OBJECT_KEY_CREATED);
 


More information about the Openais mailing list