[Openais] [PATCH]: openais/trunk: Move list_init's in saLckResourceOpenAsync

Ryan O'Hara rohara at redhat.com
Fri Jun 26 10:11:51 PDT 2009


This patch moves the list_init calls in saLckResourceOpen and
saLckResourceOpenAsync such that they occur before we send the request
to the executive. This fix is really only required for the async call,
but for consistency I changed the sync call as well.

The reason for this fix is that is is possible that the callback
generated by the saLckResourceOpenAsync call could occur before we
list_init the lists in the lckResourceInstance. There is an test in
saftest (saLckDispatch/2-3.c) that calls saLckResourceClose in the
open callback, and this requires that the lists be initialized to
avoid a segfault.

Ryan

-------------- next part --------------
Index: lib/lck.c
===================================================================
--- lib/lck.c	(revision 2000)
+++ lib/lck.c	(working copy)
@@ -525,6 +525,9 @@
 	lckResourceInstance->lck_handle = lckHandle;
 	lckResourceInstance->resource_handle = *lckResourceHandle;
 
+	list_init (&lckResourceInstance->lock_id_list);
+	list_init (&lckResourceInstance->list);
+
 	memcpy (&lckResourceInstance->resource_name, lckResourceName,
 		sizeof(SaNameT));
 
@@ -565,8 +568,6 @@
 	lckResourceInstance->resource_id =
 		res_lib_lck_resourceopen.resource_id;
 
-	list_init (&lckResourceInstance->lock_id_list);
-	list_init (&lckResourceInstance->list);
 	list_add_tail (&lckResourceInstance->list, &lckInstance->resource_list);
 
 	hdb_handle_put (&lckResourceHandleDatabase, *lckResourceHandle);
@@ -643,6 +644,9 @@
 	lckResourceInstance->lck_handle = lckHandle;
 	lckResourceInstance->resource_handle = lckResourceHandle;
 
+	list_init (&lckResourceInstance->lock_id_list);
+	list_init (&lckResourceInstance->list);
+
 	memcpy (&lckResourceInstance->resource_name, lckResourceName,
 		sizeof (SaNameT));
 
@@ -684,8 +688,6 @@
 	lckResourceInstance->resource_id =
 		res_lib_lck_resourceopenasync.resource_id;
 
-	list_init (&lckResourceInstance->lock_id_list);
-	list_init (&lckResourceInstance->list);
 	list_add_tail (&lckResourceInstance->list, &lckInstance->resource_list);
 
 	hdb_handle_put (&lckResourceHandleDatabase, lckResourceHandle);


More information about the Openais mailing list