This patch fixes initialization of lock. Currently, lock is initialized
only in handle_create. Of course, this is proper way, but some testing
programs can use directly hdb_get (before initialization of lock) and
then, problem occurs. This patch adds initialization to every functions,
which tries to lock.

Regards,
  Honza
diff --git a/trunk/include/corosync/hdb.h b/trunk/include/corosync/hdb.h
index ff14535..84cdc79 100644
--- a/trunk/include/corosync/hdb.h
+++ b/trunk/include/corosync/hdb.h
@@ -158,7 +158,7 @@ static inline int hdb_handle_create (
 
 	if (handle_database->first_run == 1) {
 		handle_database->first_run = 0;
-		hdb_database_lock_init (&handle_database->lock);
+		hdb_create (handle_database);
 	}
 	hdb_database_lock (&handle_database->lock);
 
@@ -225,6 +225,11 @@ static inline int hdb_handle_get (
 	unsigned int check = ((unsigned int)(((unsigned long long)handle_in) >> 32));
 	unsigned int handle = handle_in & 0xffffffff;
 
+	if (handle_database->first_run == 1) {
+		handle_database->first_run = 0;
+		hdb_create (handle_database);
+	}
+
 	hdb_database_lock (&handle_database->lock);
 
 	*instance = NULL;
@@ -263,6 +268,11 @@ static inline int hdb_handle_put (
 	unsigned int check = ((unsigned int)(((unsigned long long)handle_in) >> 32));
 	unsigned int handle = handle_in & 0xffffffff;
 
+	if (handle_database->first_run == 1) {
+		handle_database->first_run = 0;
+		hdb_create (handle_database);
+	}
+
 	hdb_database_lock (&handle_database->lock);
 
 	if (handle >= handle_database->handle_count) {
@@ -302,6 +312,11 @@ static inline int hdb_handle_destroy (
 	unsigned int handle = handle_in & 0xffffffff;
 	int res;
 
+	if (handle_database->first_run == 1) {
+		handle_database->first_run = 0;
+		hdb_create (handle_database);
+	}
+
 	hdb_database_lock (&handle_database->lock);
 
 	if (handle >= handle_database->handle_count) {
_______________________________________________
Openais mailing list
Openais@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to