Call a service's config_init_fn() as soon as it is loaded.

Then call exec_init_fn() after other initialisation has happened.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@958 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
Patrick Caulfield 2006-03-28 12:32:45 +00:00
parent 1363452887
commit 472e59e30a
3 changed files with 28 additions and 13 deletions

View File

@ -1185,6 +1185,7 @@ int main (int argc, char **argv)
objdb->objdb_init ();
openais_service_default_objdb_set (objdb);
openais_service_link_all (objdb, &openais_config);
res = openais_main_config_read (objdb, &error_string, &openais_config, 1);
if (res == -1) {
@ -1271,7 +1272,7 @@ int main (int argc, char **argv)
* This must occur after totempg is initialized because "this_ip" must be set
*/
this_ip = &openais_config.totem_config.interfaces[0].boundto;
openais_service_link_all (objdb, &openais_config);
openais_service_init_all (service_count, &openais_config);
sync_register (openais_sync_callbacks_retrieve, openais_sync_completed);

View File

@ -8,7 +8,7 @@
* Author: Steven Dake (sdake@mvista.com)
*
* This software licensed under BSD license, the text of which follows:
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
@ -111,7 +111,7 @@ int openais_service_objdb_add (
return (0);
}
static int service_handler_register (
static int service_handler_config (
struct openais_service_handler *handler,
struct openais_config *config)
{
@ -122,11 +122,6 @@ static int service_handler_register (
if (ais_service[handler->id]->config_init_fn) {
res = ais_service[handler->id]->config_init_fn (config);
}
//TODO error correction
log_printf (LOG_LEVEL_NOTICE, "Initializing service handler '%s'\n", handler->name);
if (ais_service[handler->id]->exec_init_fn) {
res = ais_service[handler->id]->exec_init_fn (config);
}
return (res);
}
@ -169,7 +164,7 @@ int openais_service_link_all (struct objdb_iface_ver0 *objdb,
strlen ("name"),
(void *)&service_name,
NULL);
ret = objdb->object_key_get (object_service_handle,
"ver",
strlen ("ver"),
@ -179,7 +174,7 @@ int openais_service_link_all (struct objdb_iface_ver0 *objdb,
ver_int = atoi (service_ver);
/*
* reference the interfafce and register it
* reference the interface and register it
*/
lcr_ifact_reference (
&handle,
@ -195,8 +190,23 @@ int openais_service_link_all (struct objdb_iface_ver0 *objdb,
log_printf(LOG_LEVEL_NOTICE, "openais component %s loaded.\n", service_name);
}
service_handler_register (
service_handler_config (
iface_ver0->openais_get_service_handler_ver0(), openais_config);
}
return (0);
}
int openais_service_init_all (int service_count,
struct openais_config *openais_config)
{
int i;
int res=0;
for (i = 0; i < service_count; i++) {
if (ais_service[i] && ais_service[i]->exec_init_fn) {
log_printf (LOG_LEVEL_NOTICE, "Initialising service handler '%s'\n", ais_service[i]->name);
res = ais_service[i]->exec_init_fn (openais_config);
}
}
return (res);
}

View File

@ -6,7 +6,7 @@
* Author: Steven Dake (sdake@mvista.com)
*
* This software licensed under BSD license, the text of which follows:
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
@ -59,7 +59,7 @@ struct openais_exec_handler {
void (*exec_handler_fn) (void *msg, struct totem_ip_address *source_addr);
void (*exec_endian_convert_fn) (void *msg);
};
struct openais_service_handler {
unsigned char *name;
unsigned short id;
@ -106,6 +106,10 @@ extern int openais_service_link_all (
struct objdb_iface_ver0 *objdb,
struct openais_config *openais_config);
extern int openais_service_init_all (
int service_count,
struct openais_config *openais_config);
extern struct openais_service_handler *ais_service[];
#endif /* SERVICE_H_DEFINED */