From c04cc0f1d280e8d78e1e6eb8a97939ce724279ad Mon Sep 17 00:00:00 2001 From: Steven Dake Date: Thu, 24 Jul 2008 01:30:29 +0000 Subject: [PATCH] Merge the API definitions of the objdb into the corosync api definition. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1603 fd59a12c-fef9-0310-b244-a6a79926bd2f --- corosync/Makefile | 52 +++++----- corosync/conf/corosync.conf | 31 ++++++ corosync/exec/Makefile | 8 +- corosync/exec/ipc.c | 2 +- corosync/exec/main.c | 19 +++- corosync/exec/mainconfig.c | 1 - corosync/exec/service.c | 110 ++++++++-------------- corosync/exec/service.h | 8 +- corosync/exec/timer.c | 1 - corosync/include/coroapi.h | 183 ++++++++++++++++++++++++++++++++---- corosync/services/cfg.c | 10 +- corosync/services/confdb.c | 27 +++--- corosync/services/cpg.c | 4 +- corosync/services/evs.c | 3 - 14 files changed, 300 insertions(+), 159 deletions(-) create mode 100644 corosync/conf/corosync.conf diff --git a/corosync/Makefile b/corosync/Makefile index f967f27c..085e7996 100644 --- a/corosync/Makefile +++ b/corosync/Makefile @@ -23,7 +23,7 @@ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# SUBSTITUTE GOODS OR ENGINES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF @@ -53,27 +53,27 @@ endif include $(srcdir)Makefile.inc SBINDIR=$(PREFIX)/sbin -INCLUDEDIR=$(PREFIX)/include/openais -INCLUDEDIR_TOTEM=$(PREFIX)/include/openais/totem -INCLUDEDIR_LCR=$(PREFIX)/include/openais/lcr -INCLUDEDIR_SERVICE=$(PREFIX)/include/openais/service +INCLUDEDIR=$(PREFIX)/include/corosync +INCLUDEDIR_TOTEM=$(PREFIX)/include/corosync/totem +INCLUDEDIR_LCR=$(PREFIX)/include/corosync/lcr +INCLUDEDIR_ENGINE=$(PREFIX)/include/corosync/service MANDIR=$(PREFIX)/share/man ETCDIR=/etc ARCH=$(shell uname -p) ifeq (,$(findstring 64,$(ARCH))) -LIBDIR=$(PREFIX)/lib/openais +LIBDIR=$(PREFIX)/lib/corosync else -LIBDIR=$(PREFIX)/lib64/openais +LIBDIR=$(PREFIX)/lib64/corosync endif ifeq (s390,$(ARCH)) -LIBDIR=$(PREFIX)/lib/openais +LIBDIR=$(PREFIX)/lib/corosync endif ifeq (s390x,$(ARCH)) -LIBDIR=$(PREFIX)/lib64/openais +LIBDIR=$(PREFIX)/lib64/corosync endif ifeq (ia64,$(ARCH)) -LIBDIR=$(PREFIX)/lib/openais +LIBDIR=$(PREFIX)/lib/corosync endif SUBDIRS:=$(builddir)lcr $(builddir)lib $(builddir)exec $(builddir)test @@ -105,7 +105,7 @@ help: @echo @echo Targets: @echo " all - build all targets" - @echo " install - install openais onto your system" + @echo " install - install corosync onto your system" @echo " clean - remove generated files" @echo " doxygen - doxygen html docs" @echo @@ -139,10 +139,9 @@ install: all mkdir -p $(DESTDIR)$(INCLUDEDIR) mkdir -p $(DESTDIR)$(INCLUDEDIR_TOTEM) mkdir -p $(DESTDIR)$(INCLUDEDIR_LCR) - mkdir -p $(DESTDIR)$(INCLUDEDIR_SERVICE) + mkdir -p $(DESTDIR)$(INCLUDEDIR_ENGINE) mkdir -p $(DESTDIR)$(LIBDIR) mkdir -p $(DESTDIR)$(LCRSODIR) - mkdir -p $(DESTDIR)$(ETCDIR)/ais mkdir -p $(DESTDIR)$(MANDIR)/man3 mkdir -p $(DESTDIR)$(MANDIR)/man5 mkdir -p $(DESTDIR)$(MANDIR)/man8 @@ -181,38 +180,33 @@ install: all ) \ done - echo $(LIBDIR) > "$(DESTDIR)$(ETCDIR)/ld.so.conf.d/openais-$(ARCH).conf" + echo $(LIBDIR) > "$(DESTDIR)$(ETCDIR)/ld.so.conf.d/corosync-$(ARCH).conf" install -m 755 $(builddir)exec/*lcrso $(DESTDIR)$(LCRSODIR) - install -m 755 $(builddir)exec/aisexec $(DESTDIR)$(SBINDIR) + install -m 755 $(builddir)services/*lcrso $(DESTDIR)$(LCRSODIR) + install -m 755 $(builddir)exec/corosync $(DESTDIR)$(SBINDIR) install -m 700 $(builddir)exec/keygen $(DESTDIR)$(SBINDIR)/ais-keygen - if [ ! -f $(DESTDIR)$(ETCDIR)/ais/openais.conf ] ; then \ - install -m 644 $(srcdir)conf/openais.conf $(DESTDIR)$(ETCDIR)/ais ; \ - fi - if [ ! -f $(DESTDIR)$(ETCDIR)/ais/amf.conf ] ; then \ - install -m 644 $(srcdir)conf/amf.conf $(DESTDIR)$(ETCDIR)/ais ; \ + if [ ! -f $(DESTDIR)$(ETCDIR)/penais.conf ] ; then \ + install -m 644 $(srcdir)conf/corosync.conf $(DESTDIR)$(ETCDIR) ; \ fi for aHeader in $(AIS_HEADERS); do \ install -m 644 $(srcdir)include/$$aHeader $(DESTDIR)$(INCLUDEDIR); \ done - install -m 644 $(srcdir)exec/aispoll.h $(DESTDIR)$(INCLUDEDIR_TOTEM) + install -m 644 $(srcdir)exec/coropoll.h $(DESTDIR)$(INCLUDEDIR_TOTEM) install -m 644 $(srcdir)exec/totempg.h $(DESTDIR)$(INCLUDEDIR_TOTEM) install -m 644 $(srcdir)exec/totem.h $(DESTDIR)$(INCLUDEDIR_TOTEM) install -m 644 $(srcdir)exec/totemip.h $(DESTDIR)$(INCLUDEDIR_TOTEM) install -m 644 $(srcdir)lcr/lcr_ckpt.h $(DESTDIR)$(INCLUDEDIR_LCR) install -m 644 $(srcdir)lcr/lcr_comp.h $(DESTDIR)$(INCLUDEDIR_LCR) install -m 644 $(srcdir)lcr/lcr_ifact.h $(DESTDIR)$(INCLUDEDIR_LCR) - install -m 644 $(srcdir)exec/service.h $(DESTDIR)$(INCLUDEDIR_SERVICE) - install -m 644 $(srcdir)exec/timer.h $(DESTDIR)$(INCLUDEDIR_SERVICE) - install -m 644 $(srcdir)exec/flow.h $(DESTDIR)$(INCLUDEDIR_SERVICE) - install -m 644 $(srcdir)exec/ipc.h $(DESTDIR)$(INCLUDEDIR_SERVICE) - install -m 644 $(srcdir)exec/objdb.h $(DESTDIR)$(INCLUDEDIR_SERVICE) - install -m 644 $(srcdir)exec/logsys.h $(DESTDIR)$(INCLUDEDIR_SERVICE) - install -m 644 $(srcdir)exec/config.h $(DESTDIR)$(INCLUDEDIR_SERVICE) - install -m 644 $(srcdir)include/swab.h $(DESTDIR)$(INCLUDEDIR_SERVICE) + install -m 644 $(srcdir)include/coroapi.h $(DESTDIR)$(INCLUDEDIR_ENGINE) + install -m 644 $(srcdir)exec/objdb.h $(DESTDIR)$(INCLUDEDIR_ENGINE) + install -m 644 $(srcdir)exec/logsys.h $(DESTDIR)$(INCLUDEDIR_ENGINE) + install -m 644 $(srcdir)exec/config.h $(DESTDIR)$(INCLUDEDIR_ENGINE) + install -m 644 $(srcdir)include/swab.h $(DESTDIR)$(INCLUDEDIR_ENGINE) install -m 644 $(srcdir)man/*.3 $(DESTDIR)$(MANDIR)/man3 install -m 644 $(srcdir)man/*.5 $(DESTDIR)$(MANDIR)/man5 install -m 644 $(srcdir)man/*.8 $(DESTDIR)$(MANDIR)/man8 diff --git a/corosync/conf/corosync.conf b/corosync/conf/corosync.conf new file mode 100644 index 00000000..ec70472e --- /dev/null +++ b/corosync/conf/corosync.conf @@ -0,0 +1,31 @@ +# Please read the openais.conf.5 manual page +totem { + version: 2 + secauth: off + threads: 0 + interface { + ringnumber: 0 + bindnetaddr: 192.168.1.1 + mcastaddr: 226.94.1.1 + mcastport: 5405 + } +} + +logging { + fileline: off + to_stderr: yes + to_file: yes + to_syslog: yes + logfile: /tmp/openais.log + debug: off + timestamp: on + logger { + ident: AMF + debug: off + tags: enter|leave|trace1|trace2|trace3|trace4|trace6 + } +} + +amf { + mode: disabled +} diff --git a/corosync/exec/Makefile b/corosync/exec/Makefile index 19b95274..03046400 100644 --- a/corosync/exec/Makefile +++ b/corosync/exec/Makefile @@ -63,10 +63,10 @@ LCR_SRC = vsf_ykd.c objdb.c coroparse.c LCR_OBJS =aisparser.o vsf_ykd.o objdb.o coroparse.o # main executive objects -MAIN_SRC = main.c mempool.c util.c sync.c service.c ipc.c flow.c timer.c \ - totemconfig.c mainconfig.c -MAIN_OBJS = main.o mempool.o util.o sync.o service.o ipc.o flow.o timer.o \ - totemconfig.o mainconfig.o ../lcr/lcr_ifact.o +MAIN_SRC = main.c mempool.c util.c sync.c apidef.c service.c ipc.c flow.c \ + timer.c totemconfig.c mainconfig.c +MAIN_OBJS = main.o mempool.o util.o sync.o apidef.o service.o ipc.o flow.o \ + timer.o totemconfig.o mainconfig.o ../lcr/lcr_ifact.o ifeq (${BUILD_DYNAMIC}, 1) #EXEC_OBJS = $(TOTEM_OBJS) $(LOGSYS_OBJS) $(MAIN_OBJS) diff --git a/corosync/exec/ipc.c b/corosync/exec/ipc.c index aa7903a4..237cc066 100644 --- a/corosync/exec/ipc.c +++ b/corosync/exec/ipc.c @@ -77,7 +77,6 @@ #include "tlist.h" #include "ipc.h" #include "flow.h" -#include "service.h" #include "sync.h" #include "swab.h" #include "objdb.h" @@ -85,6 +84,7 @@ #include "tlist.h" #include "logsys.h" #include "coroapi.h" +#include "service.h" #include "util.h" diff --git a/corosync/exec/main.c b/corosync/exec/main.c index 7084aa43..4218d0a7 100644 --- a/corosync/exec/main.c +++ b/corosync/exec/main.c @@ -67,7 +67,6 @@ #include "mainconfig.h" #include "totemconfig.h" #include "main.h" -#include "service.h" #include "sync.h" #include "swab.h" #include "objdb.h" @@ -79,8 +78,10 @@ #include "logsys.h" #include "util.h" #include "flow.h" -#include "version.h" #include "coroapi.h" +#include "apidef.h" +#include "service.h" +#include "version.h" LOGSYS_DECLARE_SYSTEM ("corosync", LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_BUFFER_BEFORE_CONFIG, @@ -109,6 +110,8 @@ static struct config_iface_ver0 *config_modules[MAX_DYNAMIC_SERVICES]; static struct objdb_iface_ver0 *objdb = NULL; +static struct corosync_api_v1 *api = NULL; + unsigned long long *(*main_clm_get_by_nodeid) (unsigned int node_id); static void sigusr2_handler (int num) @@ -124,8 +127,8 @@ static void sigusr2_handler (int num) static void *aisexec_exit (void *arg) { - if(objdb) { - openais_service_unlink_all (objdb); + if (api) { + openais_service_unlink_all (api); } #ifdef DEBUG_MEMPOOL @@ -559,6 +562,12 @@ int main (int argc, char **argv) objdb->objdb_init (); + /* + * Initialize the corosync_api_v1 definition + */ + apidef_init (objdb); + api = apidef_get (); + num_config_modules = 0; /* @@ -689,7 +698,7 @@ int main (int argc, char **argv) /* * This must occur after totempg is initialized because "this_ip" must be set */ - res = openais_service_defaults_link_and_init (objdb); + res = openais_service_defaults_link_and_init (api); if (res == -1) { log_printf (LOG_LEVEL_ERROR, "Could not initialize default services\n"); openais_exit_error (AIS_DONE_INIT_SERVICES); diff --git a/corosync/exec/mainconfig.c b/corosync/exec/mainconfig.c index 2bb6b04a..10bde0fb 100644 --- a/corosync/exec/mainconfig.c +++ b/corosync/exec/mainconfig.c @@ -47,7 +47,6 @@ #include "mempool.h" #include "logsys.h" #include "totem.h" -#include "service.h" static char error_string_response[512]; diff --git a/corosync/exec/service.c b/corosync/exec/service.c index efb2133f..4e0354b0 100644 --- a/corosync/exec/service.c +++ b/corosync/exec/service.c @@ -39,9 +39,7 @@ #include "../lcr/lcr_ifact.h" #include "swab.h" -#include "objdb.h" #include "totem.h" -#include "service.h" #include "mainconfig.h" #include "util.h" #include "logsys.h" @@ -51,8 +49,8 @@ #include "totemip.h" #include "main.h" #include "ipc.h" - #include "../include/coroapi.h" +#include "service.h" LOGSYS_DECLARE_SUBSYS ("SERV", LOG_INFO); @@ -61,34 +59,6 @@ struct default_service { int ver; }; -static struct corosync_api_v1 corosync_api_v1 = { - .timer_add_duration = openais_timer_add_duration, - .timer_add_absolute = openais_timer_add_absolute, - .timer_delete = openais_timer_delete, - .timer_time_get = NULL, - .ipc_source_set = message_source_set, - .ipc_source_is_local = message_source_is_local, - .ipc_private_data_get = openais_conn_private_data_get, - .ipc_response_send = NULL, - .ipc_dispatch_send = NULL, - .ipc_conn_send_response = openais_conn_send_response, - .ipc_conn_partner_get = openais_conn_partner_get, - .ipc_refcnt_inc = openais_ipc_flow_control_local_increment, - .ipc_refcnt_dec = openais_ipc_flow_control_local_decrement, - .ipc_fc_create = openais_ipc_flow_control_create, - .ipc_fc_destroy = openais_ipc_flow_control_destroy, - .totem_nodeid_get = totempg_my_nodeid_get, - .totem_ring_reenable = totempg_ring_reenable, - .totem_mcast = main_mcast, - .totem_send_ok = main_send_ok, - .totem_ifaces_get = totempg_ifaces_get, - .totem_ifaces_print = totempg_ifaces_print, - .totem_ip_print = totemip_print, - .service_link_and_init = openais_service_link_and_init, - .service_unlink_and_exit = openais_service_unlink_and_exit, - .error_memory_failure = NULL -}; - static struct default_service default_services[] = { { .name = "corosync_evs", @@ -113,7 +83,7 @@ struct corosync_service_engine *ais_service[SERVICE_HANDLER_MAXIMUM_COUNT]; static unsigned int object_internal_configuration_handle; -static unsigned int default_services_requested (struct objdb_iface_ver0 *objdb) +static unsigned int default_services_requested (struct corosync_api_v1 *api) { unsigned int object_service_handle; char *value; @@ -121,14 +91,14 @@ static unsigned int default_services_requested (struct objdb_iface_ver0 *objdb) /* * Don't link default services if they have been disabled */ - objdb->object_find_reset (OBJECT_PARENT_HANDLE); - if (objdb->object_find ( + api->object_find_reset (OBJECT_PARENT_HANDLE); + if (api->object_find ( OBJECT_PARENT_HANDLE, "aisexec", strlen ("aisexec"), &object_service_handle) == 0) { - if ( ! objdb->object_key_get (object_service_handle, + if ( ! api->object_key_get (object_service_handle, "defaultservices", strlen ("defaultservices"), (void *)&value, @@ -143,7 +113,7 @@ static unsigned int default_services_requested (struct objdb_iface_ver0 *objdb) } unsigned int openais_service_link_and_init ( - struct objdb_iface_ver0 *objdb, + struct corosync_api_v1 *api, char *service_name, unsigned int service_ver) { @@ -180,40 +150,40 @@ unsigned int openais_service_link_and_init ( ais_service[service->id] = service; if (service->config_init_fn) { - res = service->config_init_fn (objdb); + res = service->config_init_fn (api); } if (service->exec_init_fn) { - res = service->exec_init_fn (objdb, &corosync_api_v1); + res = service->exec_init_fn (api); } /* * Store service in object database */ - objdb->object_create (object_internal_configuration_handle, + api->object_create (object_internal_configuration_handle, &object_service_handle, "service", strlen ("service")); - objdb->object_key_create (object_service_handle, + api->object_key_create (object_service_handle, "name", strlen ("name"), service_name, strlen (service_name) + 1); - objdb->object_key_create (object_service_handle, + api->object_key_create (object_service_handle, "ver", strlen ("ver"), &service_ver, sizeof (service_ver)); - res = objdb->object_key_create (object_service_handle, + res = api->object_key_create (object_service_handle, "handle", strlen ("handle"), &handle, sizeof (handle)); - objdb->object_key_create (object_service_handle, + api->object_key_create (object_service_handle, "service_id", strlen ("service_id"), &service->id, @@ -224,7 +194,7 @@ unsigned int openais_service_link_and_init ( } static int openais_service_unlink_common ( - struct objdb_iface_ver0 *objdb, + struct corosync_api_v1 *api, unsigned int object_service_handle, const char *service_name, unsigned int service_version) @@ -233,13 +203,13 @@ static int openais_service_unlink_common ( unsigned short *service_id; unsigned int *found_service_handle; - res = objdb->object_key_get (object_service_handle, + res = api->object_key_get (object_service_handle, "handle", strlen ("handle"), (void *)&found_service_handle, NULL); - res = objdb->object_key_get (object_service_handle, + res = api->object_key_get (object_service_handle, "service_id", strlen ("service_id"), (void *)&service_id, @@ -249,7 +219,7 @@ static int openais_service_unlink_common ( service_name, service_version); if (ais_service[*service_id]->exec_exit_fn) { - ais_service[*service_id]->exec_exit_fn (objdb); + ais_service[*service_id]->exec_exit_fn (api); } ais_service[*service_id] = NULL; @@ -257,7 +227,7 @@ static int openais_service_unlink_common ( } extern unsigned int openais_service_unlink_and_exit ( - struct objdb_iface_ver0 *objdb, + struct corosync_api_v1 *api, char *service_name, unsigned int service_ver) { @@ -266,19 +236,19 @@ extern unsigned int openais_service_unlink_and_exit ( char *found_service_name; unsigned int *found_service_ver; - while (objdb->object_find ( + while (api->object_find ( object_internal_configuration_handle, "service", strlen ("service"), &object_service_handle) == 0) { - objdb->object_key_get (object_service_handle, + api->object_key_get (object_service_handle, "name", strlen ("name"), (void *)&found_service_name, NULL); - objdb->object_key_get (object_service_handle, + api->object_key_get (object_service_handle, "ver", strlen ("ver"), (void *)&found_service_ver, @@ -291,10 +261,10 @@ extern unsigned int openais_service_unlink_and_exit ( (service_ver == *found_service_ver)) { res = openais_service_unlink_common ( - objdb, object_service_handle, + api, object_service_handle, service_name, service_ver); - objdb->object_destroy (object_service_handle); + api->object_destroy (object_service_handle); return res; } } @@ -302,7 +272,7 @@ extern unsigned int openais_service_unlink_and_exit ( } extern unsigned int openais_service_unlink_all ( - struct objdb_iface_ver0 *objdb) + struct corosync_api_v1 *api) { char *service_name; unsigned int *service_ver; @@ -310,30 +280,30 @@ extern unsigned int openais_service_unlink_all ( log_printf(LOG_LEVEL_NOTICE, "Unloading all openais components\n"); - objdb->object_find_reset (object_internal_configuration_handle); + api->object_find_reset (object_internal_configuration_handle); - while (objdb->object_find (object_internal_configuration_handle, + while (api->object_find (object_internal_configuration_handle, "service", strlen ("service"), &object_service_handle) == 0) { - objdb->object_key_get (object_service_handle, + api->object_key_get (object_service_handle, "name", strlen ("name"), (void *)&service_name, NULL); - objdb->object_key_get (object_service_handle, + api->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); + api, object_service_handle, service_name, *service_ver); - objdb->object_destroy (object_service_handle); - objdb->object_find_reset (object_internal_configuration_handle); + api->object_destroy (object_service_handle); + api->object_find_reset (object_internal_configuration_handle); } return (0); @@ -342,7 +312,7 @@ extern unsigned int openais_service_unlink_all ( /* * Links default services into the executive */ -unsigned int openais_service_defaults_link_and_init (struct objdb_iface_ver0 *objdb) +unsigned int openais_service_defaults_link_and_init (struct corosync_api_v1 *api) { unsigned int i; @@ -351,26 +321,26 @@ unsigned int openais_service_defaults_link_and_init (struct objdb_iface_ver0 *ob char *found_service_ver; unsigned int found_service_ver_atoi; - objdb->object_create (OBJECT_PARENT_HANDLE, + api->object_create (OBJECT_PARENT_HANDLE, &object_internal_configuration_handle, "internal_configuration", strlen ("internal_configuration")); - objdb->object_find_reset (OBJECT_PARENT_HANDLE); + api->object_find_reset (OBJECT_PARENT_HANDLE); - while (objdb->object_find ( + while (api->object_find ( OBJECT_PARENT_HANDLE, "service", strlen ("service"), &object_service_handle) == 0) { - objdb->object_key_get (object_service_handle, + api->object_key_get (object_service_handle, "name", strlen ("name"), (void *)&found_service_name, NULL); - objdb->object_key_get (object_service_handle, + api->object_key_get (object_service_handle, "ver", strlen ("ver"), (void *)&found_service_ver, @@ -379,19 +349,19 @@ unsigned int openais_service_defaults_link_and_init (struct objdb_iface_ver0 *ob found_service_ver_atoi = atoi (found_service_ver); openais_service_link_and_init ( - objdb, + api, found_service_name, found_service_ver_atoi); } - if (default_services_requested (objdb) == 0) { + if (default_services_requested (api) == 0) { return (0); } for (i = 0; i < sizeof (default_services) / sizeof (struct default_service); i++) { openais_service_link_and_init ( - objdb, + api, default_services[i].name, default_services[i].ver); } diff --git a/corosync/exec/service.h b/corosync/exec/service.h index aa06d311..863b239e 100644 --- a/corosync/exec/service.h +++ b/corosync/exec/service.h @@ -39,7 +39,7 @@ * Link and initialize a service */ extern unsigned int openais_service_link_and_init ( - struct objdb_iface_ver0 *objdb, + struct corosync_api_v1 *objdb, char *service_name, unsigned int service_ver); @@ -47,7 +47,7 @@ extern unsigned int openais_service_link_and_init ( * Unlink and exit a service */ extern unsigned int openais_service_unlink_and_exit ( - struct objdb_iface_ver0 *objdb, + struct corosync_api_v1 *objdb, char *service_name, unsigned int service_ver); @@ -55,13 +55,13 @@ extern unsigned int openais_service_unlink_and_exit ( * Unlink and exit all openais services */ extern unsigned int openais_service_unlink_all ( - struct objdb_iface_ver0 *objdb); + struct corosync_api_v1 *objdb); /* * Load all of the default services */ extern unsigned int openais_service_defaults_link_and_init ( - struct objdb_iface_ver0 *objdb); + struct corosync_api_v1 *objdb); extern struct corosync_service_engine *ais_service[]; diff --git a/corosync/exec/timer.c b/corosync/exec/timer.c index 95f36194..4b5e5494 100644 --- a/corosync/exec/timer.c +++ b/corosync/exec/timer.c @@ -67,7 +67,6 @@ #include "mainconfig.h" #include "totemconfig.h" #include "main.h" -#include "service.h" #include "sync.h" #include "swab.h" #include "objdb.h" diff --git a/corosync/include/coroapi.h b/corosync/include/coroapi.h index 67967675..c292e438 100644 --- a/corosync/include/coroapi.h +++ b/corosync/include/coroapi.h @@ -34,7 +34,7 @@ #ifndef COROAPI_H_DEFINED #define COROAPI_H_DEFINED -#include "../exec/objdb.h" +#include typedef void * corosync_timer_handle_t; @@ -80,7 +80,148 @@ enum corosync_flow_control_state { }; #endif + +#ifndef OBJECT_PARENT_HANDLE + +#define OBJECT_PARENT_HANDLE 0 + +struct object_valid { + char *object_name; + int object_len; +}; + +struct object_key_valid { + char *key_name; + int key_len; + int (*validate_callback) (void *key, int key_len, void *value, int value_len); +}; + +#endif /* OBJECT_PARENT_HANDLE_DEFINED */ + struct corosync_api_v1 { + /* + * Object and configuration APIs + */ + int (*object_create) ( + unsigned int parent_object_handle, + unsigned int *object_handle, + void *object_name, unsigned int object_name_len); + + int (*object_priv_set) ( + unsigned int object_handle, + void *priv); + + int (*object_key_create) ( + unsigned int object_handle, + void *key_name, + int key_len, + void *value, + int value_len); + + int (*object_destroy) ( + unsigned int object_handle); + + int (*object_valid_set) ( + unsigned int object_handle, + struct object_valid *object_valid_list, + unsigned int object_valid_list_entries); + + int (*object_key_valid_set) ( + unsigned int object_handle, + 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) ( + unsigned int parent_object_handle, + void *object_name, + int object_name_len, + unsigned int *object_handle); + + int (*object_key_get) ( + unsigned int object_handle, + void *key_name, + int key_len, + void **value, + int *value_len); + + int (*object_priv_get) ( + unsigned int jobject_handle, + void **priv); + + int (*object_key_replace) ( + unsigned int object_handle, + void *key_name, + int key_len, + void *old_value, + int old_value_len, + void *new_value, + int new_value_len); + + int (*object_key_delete) ( + unsigned int object_handle, + void *key_name, + int key_len, + void *value, + int value_len); + + int (*object_iter_reset) ( + unsigned int parent_object_handle); + + int (*object_iter) ( + unsigned int parent_object_handle, + void **object_name, + int *name_len, + unsigned int *object_handle); + + int (*object_key_iter_reset) ( + unsigned int object_handle); + + int (*object_key_iter) ( + unsigned int parent_object_handle, + void **key_name, + int *key_len, + void **value, + int *value_len); + + int (*object_parent_get) ( + unsigned int object_handle, + unsigned int *parent_handle); + + int (*object_dump) ( + unsigned int object_handle, + FILE *file); + + int (*object_find_from) ( + unsigned int parent_object_handle, + unsigned int start_pos, + void *object_name, + int object_name_len, + unsigned int *object_handle, + unsigned int *next_pos); + + int (*object_iter_from) ( + unsigned int parent_object_handle, + unsigned int start_pos, + void **object_name, + int *name_len, + unsigned int *object_handle); + + int (*object_key_iter_from) ( + unsigned int parent_object_handle, + unsigned int start_pos, + void **key_name, + int *key_len, + void **value, + int *value_len); + + int (*object_write_config) (char **error_string); + + /* + * Time and timer APIs + */ int (*timer_add_duration) ( unsigned long long nanoseconds_in_future, void *data, @@ -98,6 +239,9 @@ struct corosync_api_v1 { unsigned long long (*timer_time_get) (void); + /* + * IPC APIs + */ void (*ipc_source_set) (mar_message_source_t *source, void *conn); int (*ipc_source_is_local) (mar_message_source_t *source); @@ -138,6 +282,9 @@ struct corosync_api_v1 { void (*ipc_refcnt_dec) (void *conn); + /* + * Totem APIs + */ int (*totem_nodeid_get) (void); int (*totem_ring_reenable) (void); @@ -146,16 +293,6 @@ struct corosync_api_v1 { int (*totem_send_ok) (struct iovec *iovec, int iov_len); - unsigned int (*service_link_and_init) ( - struct objdb_iface_ver0 *objdb, - char *service_name, - unsigned int service_ver); - - unsigned int (*service_unlink_and_exit) ( - struct objdb_iface_ver0 *objdb, - char *service_name, - unsigned int service_ver); - int (*totem_ifaces_get) ( unsigned int nodeid, struct totem_ip_address *interfaces, @@ -166,6 +303,22 @@ struct corosync_api_v1 { char *(*totem_ip_print) (struct totem_ip_address *addr); + /* + * Service loading and unloading APIs + */ + unsigned int (*service_link_and_init) ( + struct corosync_api_v1 *corosync_api_v1, + char *service_name, + unsigned int service_ver); + + unsigned int (*service_unlink_and_exit) ( + struct corosync_api_v1 *corosync_api_v1, + char *service_name, + unsigned int service_ver); + + /* + * Error handling APIs + */ void (*error_memory_failure) (void); }; @@ -194,8 +347,8 @@ struct corosync_service_engine { unsigned short id; unsigned int private_data_size; enum corosync_lib_flow_control flow_control; - int (*exec_init_fn) (struct objdb_iface_ver0 *, struct corosync_api_v1 *); - int (*exec_exit_fn) (struct objdb_iface_ver0 *); + int (*exec_init_fn) (struct corosync_api_v1 *); + int (*exec_exit_fn) (struct corosync_api_v1 *); void (*exec_dump_fn) (void); int (*lib_init_fn) (void *conn); int (*lib_exit_fn) (void *conn); @@ -203,7 +356,7 @@ struct corosync_service_engine { int lib_engine_count; struct corosync_exec_handler *exec_engine; int exec_engine_count; - int (*config_init_fn) (struct objdb_iface_ver0 *); + int (*config_init_fn) (struct corosync_api_v1 *); void (*confchg_fn) ( enum totem_configuration_type configuration_type, unsigned int *member_list, int member_list_entries, @@ -216,7 +369,5 @@ struct corosync_service_engine { void (*sync_abort) (void); }; -typedef void *corosync_timer_handle; - #endif /* COROAPI_H_DEFINED */ diff --git a/corosync/services/cfg.c b/corosync/services/cfg.c index a4d694ee..9f359d81 100644 --- a/corosync/services/cfg.c +++ b/corosync/services/cfg.c @@ -70,7 +70,7 @@ static void cfg_confchg_fn ( unsigned int *joined_list, int joined_list_entries, struct memb_ring_id *ring_id); -static int cfg_exec_init_fn (struct objdb_iface_ver0 *objdb, struct corosync_api_v1 *corosync_api_v1); +static int cfg_exec_init_fn (struct corosync_api_v1 *corosync_api_v1); static struct corosync_api_v1 *api; @@ -194,8 +194,6 @@ struct corosync_service_engine cfg_service_engine = { .confchg_fn = cfg_confchg_fn, }; -static struct objdb_iface_ver0 *my_objdb; - /* * Dynamic Loader definition */ @@ -243,10 +241,8 @@ struct req_exec_cfg_ringreenable { /* IMPL */ static int cfg_exec_init_fn ( - struct objdb_iface_ver0 *objdb, struct corosync_api_v1 *corosync_api_v1) { - my_objdb = objdb; api = corosync_api_v1; return (0); } @@ -412,7 +408,7 @@ static void message_handler_req_lib_cfg_serviceload ( ENTER(""); api->service_link_and_init ( - my_objdb, + api, (char *)req_lib_cfg_serviceload->service_name, req_lib_cfg_serviceload->service_ver); @@ -436,7 +432,7 @@ static void message_handler_req_lib_cfg_serviceunload ( ENTER(""); api->service_unlink_and_exit ( - my_objdb, + api, (char *)req_lib_cfg_serviceunload->service_name, req_lib_cfg_serviceunload->service_ver); res_lib_cfg_serviceunload.header.id = MESSAGE_RES_CFG_SERVICEUNLOAD; diff --git a/corosync/services/confdb.c b/corosync/services/confdb.c index 9cc14897..2b56b00a 100644 --- a/corosync/services/confdb.c +++ b/corosync/services/confdb.c @@ -48,12 +48,9 @@ LOGSYS_DECLARE_SUBSYS ("CONFDB", LOG_INFO); -static struct objdb_iface_ver0 *global_objdb; - static struct corosync_api_v1 *api; static int confdb_exec_init_fn ( - struct objdb_iface_ver0 *objdb, struct corosync_api_v1 *corosync_api); static int confdb_lib_init_fn (void *conn); @@ -217,11 +214,9 @@ __attribute__ ((constructor)) static void confdb_comp_register (void) { } static int confdb_exec_init_fn ( - struct objdb_iface_ver0 *objdb, struct corosync_api_v1 *corosync_api) { api = corosync_api; - global_objdb = objdb; return 0; } @@ -245,7 +240,7 @@ static void message_handler_req_lib_confdb_object_create (void *conn, void *mess unsigned int object_handle; int ret = SA_AIS_OK; - if (global_objdb->object_create(req_lib_confdb_object_create->parent_object_handle, + if (api->object_create(req_lib_confdb_object_create->parent_object_handle, &object_handle, req_lib_confdb_object_create->object_name.value, req_lib_confdb_object_create->object_name.length)) @@ -264,7 +259,7 @@ static void message_handler_req_lib_confdb_object_destroy (void *conn, void *mes mar_res_header_t res; int ret = SA_AIS_OK; - if (global_objdb->object_destroy(req_lib_confdb_object_destroy->object_handle)) + if (api->object_destroy(req_lib_confdb_object_destroy->object_handle)) ret = SA_AIS_ERR_ACCESS; res.size = sizeof(res); @@ -280,7 +275,7 @@ static void message_handler_req_lib_confdb_key_create (void *conn, void *message mar_res_header_t res; int ret = SA_AIS_OK; - if (global_objdb->object_key_create(req_lib_confdb_key_create->object_handle, + if (api->object_key_create(req_lib_confdb_key_create->object_handle, req_lib_confdb_key_create->key_name.value, req_lib_confdb_key_create->key_name.length, req_lib_confdb_key_create->value.value, @@ -301,7 +296,7 @@ static void message_handler_req_lib_confdb_key_get (void *conn, void *message) void *value; int ret = SA_AIS_OK; - if (global_objdb->object_key_get(req_lib_confdb_key_get->parent_object_handle, + if (api->object_key_get(req_lib_confdb_key_get->parent_object_handle, req_lib_confdb_key_get->key_name.value, req_lib_confdb_key_get->key_name.length, &value, @@ -324,7 +319,7 @@ static void message_handler_req_lib_confdb_key_replace (void *conn, void *messag mar_res_header_t res; int ret = SA_AIS_OK; - if (global_objdb->object_key_replace(req_lib_confdb_key_replace->object_handle, + if (api->object_key_replace(req_lib_confdb_key_replace->object_handle, req_lib_confdb_key_replace->key_name.value, req_lib_confdb_key_replace->key_name.length, req_lib_confdb_key_replace->old_value.value, @@ -345,7 +340,7 @@ static void message_handler_req_lib_confdb_key_delete (void *conn, void *message mar_res_header_t res; int ret = SA_AIS_OK; - if (global_objdb->object_key_delete(req_lib_confdb_key_delete->object_handle, + if (api->object_key_delete(req_lib_confdb_key_delete->object_handle, req_lib_confdb_key_delete->key_name.value, req_lib_confdb_key_delete->key_name.length, req_lib_confdb_key_delete->value.value, @@ -365,7 +360,7 @@ static void message_handler_req_lib_confdb_object_parent_get (void *conn, void * unsigned int object_handle; int ret = SA_AIS_OK; - if (global_objdb->object_parent_get(req_lib_confdb_object_parent_get->object_handle, + if (api->object_parent_get(req_lib_confdb_object_parent_get->object_handle, &object_handle)) ret = SA_AIS_ERR_ACCESS; @@ -387,7 +382,7 @@ static void message_handler_req_lib_confdb_key_iter (void *conn, void *message) int value_len; int ret = SA_AIS_OK; - if (global_objdb->object_key_iter_from(req_lib_confdb_key_iter->parent_object_handle, + if (api->object_key_iter_from(req_lib_confdb_key_iter->parent_object_handle, req_lib_confdb_key_iter->next_entry, &key_name, &key_name_len, @@ -415,7 +410,7 @@ static void message_handler_req_lib_confdb_object_iter (void *conn, void *messag int object_name_len; int ret = SA_AIS_OK; - if (global_objdb->object_iter_from(req_lib_confdb_object_iter->parent_object_handle, + if (api->object_iter_from(req_lib_confdb_object_iter->parent_object_handle, req_lib_confdb_object_iter->next_entry, &object_name, &object_name_len, @@ -438,7 +433,7 @@ static void message_handler_req_lib_confdb_object_find (void *conn, void *messag struct res_lib_confdb_object_find res_lib_confdb_object_find; int ret = SA_AIS_OK; - if (global_objdb->object_find_from(req_lib_confdb_object_find->parent_object_handle, + if (api->object_find_from(req_lib_confdb_object_find->parent_object_handle, req_lib_confdb_object_find->next_entry, req_lib_confdb_object_find->object_name.value, req_lib_confdb_object_find->object_name.length, @@ -459,7 +454,7 @@ static void message_handler_req_lib_confdb_write (void *conn, void *message) int ret = SA_AIS_OK; char *error_string = NULL; - if (global_objdb->object_write_config(&error_string)) + if (api->object_write_config(&error_string)) ret = SA_AIS_ERR_ACCESS; res_lib_confdb_write.header.size = sizeof(res_lib_confdb_write); diff --git a/corosync/services/cpg.c b/corosync/services/cpg.c index b3770b5e..f03ba018 100644 --- a/corosync/services/cpg.c +++ b/corosync/services/cpg.c @@ -124,7 +124,7 @@ static void cpg_confchg_fn ( unsigned int *joined_list, int joined_list_entries, struct memb_ring_id *ring_id); -static int cpg_exec_init_fn (struct objdb_iface_ver0 *objdb, struct corosync_api_v1 *); +static int cpg_exec_init_fn (struct corosync_api_v1 *); static int cpg_lib_init_fn (void *conn); @@ -465,7 +465,7 @@ static void remove_group(struct group_info *gi) } -static int cpg_exec_init_fn (struct objdb_iface_ver0 *objdb, struct corosync_api_v1 *corosync_api) +static int cpg_exec_init_fn (struct corosync_api_v1 *corosync_api) { int i; diff --git a/corosync/services/evs.c b/corosync/services/evs.c index 9a37c5a2..655af72a 100644 --- a/corosync/services/evs.c +++ b/corosync/services/evs.c @@ -67,7 +67,6 @@ enum evs_exec_message_req_types { * Service Interfaces required by service_message_handler struct */ static int evs_exec_init_fn ( - struct objdb_iface_ver0 *objdb, struct corosync_api_v1 *corosync_api); static void evs_confchg_fn ( @@ -200,10 +199,8 @@ __attribute__ ((constructor)) static void evs_comp_register (void) { } static int evs_exec_init_fn ( - struct objdb_iface_ver0 *objdb, struct corosync_api_v1 *corosync_api) { - (void) objdb; api = corosync_api; return 0;