currently the objdb interface is in a bit of a messy state. The reason
is the need for iteration contexts for multiple iterators on the same
object or different objects at around the same time.
This patch removes objdb_find_reset and objdb_find and replaces them
with object_find_create, object_find_next, and object_find_destroy.
When an iterator is created, objdb_find_create is used. This creates a
handle context which then can be used with objdb_find_next to iterate
that object. Once the service engine is done with the iterator, it
would call object_find_destroy.
At this time object deletion is not supported during iteration, but that
will be added in a future patch as the need arises.
Next up is the key iteration following this same api model.
After that work in complete confdb will be changed internally to use
these interfaces.
Regards
-steve
Index: exec/amfutil.c
===================================================================
--- exec/amfutil.c (revision 1547)
+++ exec/amfutil.c (working copy)
@@ -10,6 +10,8 @@
* - Refactoring of code into several AMF files
* - Serializers/deserializers
*
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ *
* All rights reserved.
*
* This software licensed under BSD license, the text of which follows:
@@ -1009,12 +1011,16 @@
unsigned int object_service_handle;
char *value;
int enabled = 0;
+ unsigned int object_find_handle;
- objdb->object_find_reset (OBJECT_PARENT_HANDLE);
- if (objdb->object_find (
+ objdb->object_find_create (
OBJECT_PARENT_HANDLE,
"amf",
strlen ("amf"),
+ &object_find_handle);
+
+ if (objdb->object_find_next (
+ object_find_handle,
&object_service_handle) == 0) {
value = NULL;
@@ -1033,6 +1039,8 @@
}
}
+ objdb->object_find_destroy (object_find_handle);
+
return enabled;
}
Index: exec/service.c
===================================================================
--- exec/service.c (revision 1547)
+++ exec/service.c (working copy)
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2006 MontaVista Software, Inc.
- * Copyright (c) 2006-2007 Red Hat, Inc.
+ * Copyright (c) 2006-2008 Red Hat, Inc.
*
* All rights reserved.
*
@@ -105,16 +105,20 @@
static unsigned int default_services_requested (struct objdb_iface_ver0 *objdb)
{
unsigned int object_service_handle;
+ unsigned int object_find_handle;
char *value;
/*
* Don't link default services if they have been disabled
*/
- objdb->object_find_reset (OBJECT_PARENT_HANDLE);
- if (objdb->object_find (
+ objdb->object_find_create (
OBJECT_PARENT_HANDLE,
"aisexec",
strlen ("aisexec"),
+ &object_find_handle);
+
+ if (objdb->object_find_next (
+ object_find_handle,
&object_service_handle) == 0) {
if ( ! objdb->object_key_get (object_service_handle,
@@ -128,7 +132,10 @@
}
}
}
- return (-1);
+
+ objdb->object_find_destroy (object_find_handle);
+
+ return (-1);
}
unsigned int openais_service_link_and_init (
@@ -254,11 +261,16 @@
unsigned int object_service_handle;
char *found_service_name;
unsigned int *found_service_ver;
+ unsigned int object_find_handle;
- while (objdb->object_find (
+ objdb->object_find_create (
object_internal_configuration_handle,
"service",
strlen ("service"),
+ &object_find_handle);
+
+ while (objdb->object_find_next (
+ object_find_handle,
&object_service_handle) == 0) {
objdb->object_key_get (object_service_handle,
@@ -287,6 +299,9 @@
return res;
}
}
+
+ objdb->object_find_destroy (object_find_handle);
+
return (-1);
}
@@ -296,33 +311,57 @@
char *service_name;
unsigned int *service_ver;
unsigned int object_service_handle;
+ unsigned int object_find_handle;
+ unsigned int res;
log_printf(LOG_LEVEL_NOTICE, "Unloading all openais components\n");
- objdb->object_find_reset (object_internal_configuration_handle);
+ res = 0;
+ /*
+ * TODO
+ * Deleting of keys not supported during iteration at this time
+ * hence this ugly hack
+ */
+ for (;;) {
+ objdb->object_find_create (
+ object_internal_configuration_handle,
+ "service",
+ strlen ("service"),
+ &object_find_handle);
- while (objdb->object_find (object_internal_configuration_handle,
- "service",
- strlen ("service"),
- &object_service_handle) == 0) {
-
- objdb->object_key_get (object_service_handle,
+ res = objdb->object_find_next (
+ object_find_handle,
+ &object_service_handle);
+
+ /*
+ * Exit from unloading
+ */
+ if (res == -1) {
+ break;
+ }
+
+ objdb->object_key_get (
+ object_service_handle,
"name",
strlen ("name"),
(void *)&service_name,
NULL);
- objdb->object_key_get (object_service_handle,
+ objdb->object_key_get (
+ object_service_handle,
"ver",
strlen ("ver"),
(void *)&service_ver,
NULL);
-
+
openais_service_unlink_common (
- objdb, object_service_handle, service_name, *service_ver);
+ objdb, object_service_handle,
+ service_name, *service_ver);
objdb->object_destroy (object_service_handle);
- objdb->object_find_reset (object_internal_configuration_handle);
+
+ objdb->object_find_destroy (object_find_handle);
+
}
return (0);
@@ -339,18 +378,21 @@
char *found_service_name;
char *found_service_ver;
unsigned int found_service_ver_atoi;
+ unsigned int object_find_handle;
objdb->object_create (OBJECT_PARENT_HANDLE,
&object_internal_configuration_handle,
"internal_configuration",
strlen ("internal_configuration"));
- objdb->object_find_reset (OBJECT_PARENT_HANDLE);
-
- while (objdb->object_find (
+ objdb->object_find_create (
OBJECT_PARENT_HANDLE,
"service",
strlen ("service"),
+ &object_find_handle);
+
+ while (objdb->object_find_next (
+ object_find_handle,
&object_service_handle) == 0) {
objdb->object_key_get (object_service_handle,
@@ -373,9 +415,12 @@
found_service_ver_atoi);
}
+ objdb->object_find_destroy (object_find_handle);
+
if (default_services_requested (objdb) == 0) {
return (0);
}
+
for (i = 0;
i < sizeof (default_services) / sizeof (struct default_service); i++) {
Index: exec/objdb.c
===================================================================
--- exec/objdb.c (revision 1547)
+++ exec/objdb.c (working copy)
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2006 MontaVista Software, Inc.
- * Copyright (c) 2008 Red Hat, Inc.
+ * Copyright (c) 2007-2008 Red Hat, Inc.
*
* All rights reserved.
*
@@ -68,6 +68,13 @@
int object_key_valid_list_entries;
};
+struct object_find_instance {
+ struct list_head *find_child_list;
+ struct list_head *child_head;
+ void *object_name;
+ int object_len;
+};
+
struct objdb_iface_ver0 objdb_iface;
static struct hdb_handle_database object_instance_database = {
@@ -77,7 +84,14 @@
.mutex = PTHREAD_MUTEX_INITIALIZER
};
+static struct hdb_handle_database object_find_instance_database = {
+ .handle_count = 0,
+ .handles = 0,
+ .iterator = 0,
+ .mutex = PTHREAD_MUTEX_INITIALIZER
+};
+
static int objdb_init (void)
{
unsigned int handle;
@@ -439,61 +453,89 @@
/*
* object db reading
*/
-static int object_find_reset (
- unsigned int object_handle)
+static int object_find_create (
+ unsigned int object_handle,
+ void *object_name,
+ int object_len,
+ unsigned int *object_find_handle)
{
unsigned int res;
- struct object_instance *instance;
+ struct object_instance *object_instance;
+ struct object_find_instance *object_find_instance;
res = hdb_handle_get (&object_instance_database,
- object_handle, (void *)&instance);
+ object_handle, (void *)&object_instance);
if (res != 0) {
goto error_exit;
}
- instance->find_child_list = &instance->child_head;
+ res = hdb_handle_create (&object_find_instance_database,
+ sizeof (struct object_find_instance), object_find_handle);
+ if (res != 0) {
+ goto error_put;
+ }
+ res = hdb_handle_get (&object_find_instance_database,
+ *object_find_handle, (void *)&object_find_instance);
+ if (res != 0) {
+ goto error_destroy;
+ }
+
+ object_find_instance->find_child_list = &object_instance->child_head;
+ object_find_instance->child_head = &object_instance->child_head;
+ object_find_instance->object_name = object_name;
+ object_find_instance->object_len = object_len;
+
hdb_handle_put (&object_instance_database, object_handle);
+ hdb_handle_put (&object_find_instance_database, *object_find_handle);
return (0);
+error_destroy:
+ hdb_handle_destroy (&object_instance_database, *object_find_handle);
+
+error_put:
+ hdb_handle_put (&object_instance_database, object_handle);
+
error_exit:
return (-1);
}
-static int object_find (
- unsigned int parent_object_handle,
- void *object_name,
- int object_name_len,
+static int object_find_next (
+ unsigned int object_find_handle,
unsigned int *object_handle)
{
unsigned int res;
- struct object_instance *instance;
- struct object_instance *find_instance = NULL;
+ struct object_find_instance *object_find_instance;
+ struct object_instance *object_instance = NULL;
struct list_head *list;
unsigned int found = 0;
- res = hdb_handle_get (&object_instance_database,
- parent_object_handle, (void *)&instance);
+ res = hdb_handle_get (&object_find_instance_database,
+ object_find_handle, (void *)&object_find_instance);
if (res != 0) {
goto error_exit;
}
- res = -ENOENT;
- for (list = instance->find_child_list->next;
- list != &instance->child_head; list = list->next) {
+ res = -1;
+ for (list = object_find_instance->find_child_list->next;
+ list != object_find_instance->child_head; list = list->next) {
- find_instance = list_entry (list, struct object_instance,
+ object_instance = list_entry (list, struct object_instance,
child_list);
- if ((find_instance->object_name_len == object_name_len) &&
- (memcmp (find_instance->object_name, object_name,
- object_name_len) == 0)) {
+ if ((object_instance->object_name_len ==
+ object_find_instance->object_len) &&
+
+ (memcmp (object_instance->object_name,
+ object_find_instance->object_name,
+ object_find_instance->object_len) == 0)) {
+
found = 1;
break;
}
}
- instance->find_child_list = list;
- hdb_handle_put (&object_instance_database, parent_object_handle);
+ object_find_instance->find_child_list = list;
+ hdb_handle_put (&object_find_instance_database, object_find_handle);
if (found) {
- *object_handle = find_instance->object_handle;
+ *object_handle = object_instance->object_handle;
res = 0;
}
return (res);
@@ -502,6 +544,12 @@
return (-1);
}
+static int object_find_destroy (
+ unsigned int object_find_handle)
+{
+ return (0);
+}
+
static int object_key_get (
unsigned int object_handle,
void *key_name,
@@ -1117,8 +1165,9 @@
.object_destroy = object_destroy,
.object_valid_set = object_valid_set,
.object_key_valid_set = object_key_valid_set,
- .object_find_reset = object_find_reset,
- .object_find = object_find,
+ .object_find_create = object_find_create,
+ .object_find_next = object_find_next,
+ .object_find_destroy = object_find_destroy,
.object_find_from = object_find_from,
.object_key_get = object_key_get,
.object_key_iter = object_key_iter,
Index: exec/objdb.h
===================================================================
--- exec/objdb.h (revision 1547)
+++ exec/objdb.h (working copy)
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2006 MontaVista Software, Inc.
+ * Copyright (c) 2007-2008 Red Hat, Inc.
*
* All rights reserved.
*
@@ -83,15 +84,19 @@
struct object_key_valid *object_key_valid_list,
unsigned int object_key_valid_list_entries);
- int (*object_find_reset) (
- unsigned int parent_object_handle);
-
- int (*object_find) (
+ int (*object_find_create) (
unsigned int parent_object_handle,
void *object_name,
int object_name_len,
+ unsigned int *object_find_handle);
+
+ int (*object_find_next) (
+ unsigned int object_find_handle,
unsigned int *object_handle);
+ int (*object_find_destroy) (
+ unsigned int object_find_handle);
+
int (*object_key_get) (
unsigned int object_handle,
void *key_name,
Index: exec/evt.c
===================================================================
--- exec/evt.c (revision 1547)
+++ exec/evt.c (working copy)
@@ -2,6 +2,7 @@
* Copyright (c) 2004-2006 Mark Haverkamp
* Copyright (c) 2004-2006 Open Source Development Lab
* Copyright (c) 2006 Sun Microsystems, Inc.
+ * Copyright (c) 2007-2008 Red Hat, Inc.
*
* All rights reserved.
*
@@ -3111,17 +3112,21 @@
static int evt_exec_init(struct objdb_iface_ver0 *objdb)
{
unsigned int object_service_handle;
+ unsigned int object_find_handle;
char *value;
log_printf(LOG_LEVEL_DEBUG, "Evt exec init request\n");
- objdb->object_find_reset (OBJECT_PARENT_HANDLE);
- if (objdb->object_find (
- OBJECT_PARENT_HANDLE,
- "event",
- strlen ("event"),
- &object_service_handle) == 0) {
+ objdb->object_find_create (
+ OBJECT_PARENT_HANDLE,
+ "event",
+ strlen ("event"),
+ &object_find_handle);
+ if (objdb->object_find_next (
+ object_find_handle,
+ &object_service_handle) == 0) {
+
value = NULL;
if ( !objdb->object_key_get (object_service_handle,
"delivery_queue_size",
@@ -3145,6 +3150,7 @@
evt_delivery_queue_size);
}
}
+ objdb->object_find_destroy (object_find_handle);
/*
* Create an event to be sent when we have to drop messages
Index: exec/mainconfig.c
===================================================================
--- exec/mainconfig.c (revision 1547)
+++ exec/mainconfig.c (working copy)
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2002-2005 MontaVista Software, Inc.
+ * Copyright (c) 2006-2008 Red Hat, Inc.
*
* All rights reserved.
*
@@ -106,17 +107,21 @@
unsigned int object_logger_subsys_handle;
char *value;
char *error_reason = error_string_response;
+ unsigned int object_find_handle;
+ unsigned int object_find_logsys_handle;
memset (main_config, 0, sizeof (struct main_config));
- objdb->object_find_reset (OBJECT_PARENT_HANDLE);
+ objdb->object_find_create (
+ OBJECT_PARENT_HANDLE,
+ "logging",
+ strlen ("logging"),
+ &object_find_handle);
main_config->logmode = LOG_MODE_FLUSH_AFTER_CONFIG;
- if (objdb->object_find (
- OBJECT_PARENT_HANDLE,
- "logging",
- strlen ("logging"),
- &object_service_handle) == 0) {
+ if (objdb->object_find_next (
+ object_find_handle,
+ &object_service_handle) == 0) {
if (!objdb_get_string (objdb,object_service_handle, "to_file", &value)) {
if (strcmp (value, "yes") == 0) {
@@ -211,9 +216,14 @@
}
}
- while (objdb->object_find (object_service_handle,
+ objdb->object_find_create (
+ object_service_handle,
"logger_subsys",
strlen ("logger_subsys"),
+ &object_find_logsys_handle);
+
+ while (objdb->object_find_next (
+ object_find_logsys_handle,
&object_logger_subsys_handle) == 0) {
if (!objdb_get_string (objdb,
@@ -278,15 +288,21 @@
logsys_logger.priority);
}
+ objdb->object_find_destroy (object_find_logsys_handle);
}
- objdb->object_find_reset (OBJECT_PARENT_HANDLE);
- if (objdb->object_find (
- OBJECT_PARENT_HANDLE,
- "aisexec",
- strlen ("aisexec"),
- &object_service_handle) == 0) {
+ objdb->object_find_destroy (object_find_handle);
+ objdb->object_find_create (
+ OBJECT_PARENT_HANDLE,
+ "aisexec",
+ strlen ("aisexec"),
+ &object_find_handle);
+
+ if (objdb->object_find_next (
+ object_find_handle,
+ &object_service_handle) == 0) {
+
if (!objdb_get_string (objdb,object_service_handle, "user", &value)) {
main_config->user = strdup(value);
}
@@ -295,6 +311,8 @@
}
}
+ objdb->object_find_destroy (object_find_handle);
+
/* Default user/group */
if (!main_config->user)
main_config->user = "ais";
Index: exec/totemconfig.c
===================================================================
--- exec/totemconfig.c (revision 1547)
+++ exec/totemconfig.c (working copy)
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2002-2005 MontaVista Software, Inc.
- * Copyright (c) 2006 RedHat, Inc.
+ * Copyright (c) 2006-2008 Red Hat, Inc.
*
* All rights reserved.
*
@@ -77,19 +77,22 @@
/* These just makes the code below a little neater */
static inline int objdb_get_string (
- struct objdb_iface_ver0 *objdb, unsigned int object_service_handle,
+ struct objdb_iface_ver0 *objdb,
+ unsigned int object_service_handle,
char *key, char **value)
{
int res;
*value = NULL;
if ( !(res = objdb->object_key_get (object_service_handle,
- key,
- strlen (key),
- (void *)value,
- NULL))) {
- if (*value)
+ key,
+ strlen (key),
+ (void *)value,
+ NULL))) {
+
+ if (*value) {
return 0;
+ }
}
return -1;
}
@@ -101,17 +104,63 @@
char *value = NULL;
if (!objdb->object_key_get (object_service_handle,
- key,
- strlen (key),
- (void *)&value,
- NULL)) {
+ key,
+ strlen (key),
+ (void *)&value,
+ NULL)) {
+
if (value) {
*intvalue = atoi(value);
}
}
}
+static unsigned int totem_handle_find (
+ struct objdb_iface_ver0 *objdb,
+ unsigned int *totem_find_handle) {
+ unsigned int object_find_handle;
+ unsigned int res;
+
+ /*
+ * Find a network section
+ */
+ objdb->object_find_create (
+ OBJECT_PARENT_HANDLE,
+ "network",
+ strlen ("network"),
+ &object_find_handle);
+
+ res = objdb->object_find_next (
+ object_find_handle,
+ totem_find_handle);
+
+ objdb->object_find_destroy (object_find_handle);
+
+ /*
+ * Network section not found in configuration, checking for totem
+ */
+ if (res == -1) {
+ objdb->object_find_create (
+ OBJECT_PARENT_HANDLE,
+ "totem",
+ strlen ("totem"),
+ &object_find_handle);
+
+ res = objdb->object_find_next (
+ object_find_handle,
+ totem_find_handle);
+
+ objdb->object_find_destroy (object_find_handle);
+ }
+
+ if (res == -1) {
+ return (-1);
+ }
+
+ return (0);
+}
+
extern int totem_config_read (
struct objdb_iface_ver0 *objdb,
struct totem_config *totem_config,
@@ -122,7 +171,14 @@
unsigned int object_interface_handle;
char *str;
unsigned int ringnumber = 0;
+ unsigned int object_find_interface_handle;
+ res = totem_handle_find (objdb, &object_totem_handle);
+ if (res == -1) {
+printf ("couldn't find totem handle\n");
+ return (-1);
+ }
+
memset (totem_config, 0, sizeof (struct totem_config));
totem_config->interfaces = malloc (sizeof (struct totem_interface) * INTERFACE_MAX);
if (totem_config->interfaces == 0) {
@@ -137,88 +193,79 @@
strcpy (totem_config->rrp_mode, "none");
- objdb->object_find_reset (OBJECT_PARENT_HANDLE);
-
- if (objdb->object_find (
- OBJECT_PARENT_HANDLE,
- "network",
- strlen ("network"),
- &object_totem_handle) == 0 ||
- objdb->object_find (
- OBJECT_PARENT_HANDLE,
- "totem",
- strlen ("totem"),
- &object_totem_handle) == 0) {
-
- if (!objdb_get_string (objdb,object_totem_handle, "version", &str)) {
- if (strcmp (str, "2") == 0) {
- totem_config->version = 2;
- }
+ if (!objdb_get_string (objdb, object_totem_handle, "version", &str)) {
+ if (strcmp (str, "2") == 0) {
+ totem_config->version = 2;
}
- if (!objdb_get_string (objdb,object_totem_handle, "secauth", &str)) {
- if (strcmp (str, "on") == 0) {
- totem_config->secauth = 1;
- }
- if (strcmp (str, "off") == 0) {
- totem_config->secauth = 0;
- }
+ }
+ if (!objdb_get_string (objdb, object_totem_handle, "secauth", &str)) {
+ if (strcmp (str, "on") == 0) {
+ totem_config->secauth = 1;
}
- if (!objdb_get_string (objdb, object_totem_handle, "rrp_mode", &str)) {
- strcpy (totem_config->rrp_mode, str);
+ if (strcmp (str, "off") == 0) {
+ totem_config->secauth = 0;
}
+ }
+ if (!objdb_get_string (objdb, object_totem_handle, "rrp_mode", &str)) {
+ strcpy (totem_config->rrp_mode, str);
+ }
- /*
- * Get interface node id
- */
- objdb_get_int (objdb, object_totem_handle, "nodeid", &totem_config->node_id);
+ /*
+ * Get interface node id
+ */
+ objdb_get_int (objdb, object_totem_handle, "nodeid", &totem_config->node_id);
- objdb_get_int (objdb,object_totem_handle, "threads", &totem_config->threads);
+ objdb_get_int (objdb,object_totem_handle, "threads", &totem_config->threads);
- objdb_get_int (objdb,object_totem_handle, "netmtu", &totem_config->net_mtu);
+ objdb_get_int (objdb,object_totem_handle, "netmtu", &totem_config->net_mtu);
- objdb_get_int (objdb,object_totem_handle, "token", &totem_config->token_timeout);
+ objdb_get_int (objdb,object_totem_handle, "token", &totem_config->token_timeout);
- objdb_get_int (objdb,object_totem_handle, "token_retransmit", &totem_config->token_retransmit_timeout);
+ objdb_get_int (objdb,object_totem_handle, "token_retransmit", &totem_config->token_retransmit_timeout);
- objdb_get_int (objdb,object_totem_handle, "hold", &totem_config->token_hold_timeout);
+ objdb_get_int (objdb,object_totem_handle, "hold", &totem_config->token_hold_timeout);
- objdb_get_int (objdb,object_totem_handle, "token_retransmits_before_loss_const", &totem_config->token_retransmits_before_loss_const);
+ objdb_get_int (objdb,object_totem_handle, "token_retransmits_before_loss_const", &totem_config->token_retransmits_before_loss_const);
- objdb_get_int (objdb,object_totem_handle, "join", &totem_config->join_timeout);
- objdb_get_int (objdb,object_totem_handle, "send_join", &totem_config->send_join_timeout);
+ objdb_get_int (objdb,object_totem_handle, "join", &totem_config->join_timeout);
+ objdb_get_int (objdb,object_totem_handle, "send_join", &totem_config->send_join_timeout);
- objdb_get_int (objdb,object_totem_handle, "consensus", &totem_config->consensus_timeout);
+ objdb_get_int (objdb,object_totem_handle, "consensus", &totem_config->consensus_timeout);
- objdb_get_int (objdb,object_totem_handle, "merge", &totem_config->merge_timeout);
+ objdb_get_int (objdb,object_totem_handle, "merge", &totem_config->merge_timeout);
- objdb_get_int (objdb,object_totem_handle, "downcheck", &totem_config->downcheck_timeout);
+ objdb_get_int (objdb,object_totem_handle, "downcheck", &totem_config->downcheck_timeout);
- objdb_get_int (objdb,object_totem_handle, "fail_recv_const", &totem_config->fail_to_recv_const);
+ objdb_get_int (objdb,object_totem_handle, "fail_recv_const", &totem_config->fail_to_recv_const);
- objdb_get_int (objdb,object_totem_handle, "seqno_unchanged_const", &totem_config->seqno_unchanged_const);
+ objdb_get_int (objdb,object_totem_handle, "seqno_unchanged_const", &totem_config->seqno_unchanged_const);
- objdb_get_int (objdb,object_totem_handle, "rrp_token_expired_timeout", &totem_config->rrp_token_expired_timeout);
+ objdb_get_int (objdb,object_totem_handle, "rrp_token_expired_timeout", &totem_config->rrp_token_expired_timeout);
- objdb_get_int (objdb,object_totem_handle, "rrp_problem_count_timeout", &totem_config->rrp_problem_count_timeout);
+ objdb_get_int (objdb,object_totem_handle, "rrp_problem_count_timeout", &totem_config->rrp_problem_count_timeout);
- objdb_get_int (objdb,object_totem_handle, "rrp_problem_count_threshold", &totem_config->rrp_problem_count_threshold);
+ objdb_get_int (objdb,object_totem_handle, "rrp_problem_count_threshold", &totem_config->rrp_problem_count_threshold);
- objdb_get_int (objdb,object_totem_handle, "heartbeat_failures_allowed", &totem_config->heartbeat_failures_allowed);
+ objdb_get_int (objdb,object_totem_handle, "heartbeat_failures_allowed", &totem_config->heartbeat_failures_allowed);
- objdb_get_int (objdb,object_totem_handle, "max_network_delay", &totem_config->max_network_delay);
+ objdb_get_int (objdb,object_totem_handle, "max_network_delay", &totem_config->max_network_delay);
- objdb_get_int (objdb,object_totem_handle, "window_size", &totem_config->window_size);
- objdb_get_string (objdb, object_totem_handle, "vsftype", &totem_config->vsf_type);
+ objdb_get_int (objdb,object_totem_handle, "window_size", &totem_config->window_size);
+ objdb_get_string (objdb, object_totem_handle, "vsftype", &totem_config->vsf_type);
- objdb_get_int (objdb,object_totem_handle, "max_messages", &totem_config->max_messages);
- }
- while (objdb->object_find (
- object_totem_handle,
- "interface",
- strlen ("interface"),
- &object_interface_handle) == 0) {
+ objdb_get_int (objdb,object_totem_handle, "max_messages", &totem_config->max_messages);
+ objdb->object_find_create (
+ object_totem_handle,
+ "interface",
+ strlen ("interface"),
+ &object_find_interface_handle);
+
+ while (objdb->object_find_next (
+ object_find_interface_handle,
+ &object_interface_handle) == 0) {
+
objdb_get_int (objdb, object_interface_handle, "ringnumber", &ringnumber);
/*
@@ -246,9 +293,9 @@
totem_config->interface_count++;
}
+ objdb->object_find_destroy (object_find_interface_handle);
+
return 0;
-
- return (-1);
}
int totem_config_validate (
@@ -553,7 +600,7 @@
{
int got_key = 0;
char *key_location = NULL;
- unsigned int object_service_handle;
+ unsigned int object_totem_handle;
int res;
memset (totem_config->private_key, 0, 128);
@@ -563,39 +610,32 @@
return (0);
}
- if (objdb->object_find (
- OBJECT_PARENT_HANDLE,
- "network",
- strlen ("network"),
- &object_service_handle) == 0 ||
- objdb->object_find (
- OBJECT_PARENT_HANDLE,
- "totem",
- strlen ("totem"),
- &object_service_handle) == 0) {
+ res = totem_handle_find (objdb, &object_totem_handle);
+ if (res == -1) {
+ return (-1);
+ }
+ /* objdb may store the location of the key file */
+ if (!objdb_get_string (objdb,object_totem_handle, "keyfile", &key_location)
+ && key_location) {
+ res = read_keyfile(key_location, totem_config, error_string);
+ if (res) {
+ goto key_error;
+ }
+ got_key = 1;
+ } else { /* Or the key itself may be in the objdb */
+ char *key = NULL;
+ int key_len;
+ res = objdb->object_key_get (object_totem_handle,
+ "key",
+ strlen ("key"),
+ (void *)&key,
+ &key_len);
- /* objdb may store the location of the key file */
- if (!objdb_get_string (objdb,object_service_handle, "keyfile", &key_location)
- && key_location) {
- res = read_keyfile(key_location, totem_config, error_string);
- if (res)
- goto key_error;
+ if (res == 0 && key) {
+ memcpy(totem_config->private_key, key, key_len);
+ totem_config->private_key_len = key_len;
got_key = 1;
}
- else { /* Or the key itself may be in the objdb */
- char *key = NULL;
- int key_len;
- res = objdb->object_key_get (object_service_handle,
- "key",
- strlen ("key"),
- (void *)&key,
- &key_len);
- if (res == 0 && key) {
- memcpy(totem_config->private_key, key, key_len);
- totem_config->private_key_len = key_len;
- got_key = 1;
- }
- }
}
/* In desperation we read the default filename */
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais