mirror of
https://git.proxmox.com/git/mirror_corosync
synced 2025-08-05 16:37:54 +00:00
This is a major rework of the service handling code. Now service handlers
can be dynamically loaded via the live component replacement service. Sync handlers are also dynamically contributed. It is possible to build using either dynamic loading via LCR or static linking of the entire executive. This is controlled by the BUILD_DYNAMIC configuration option in the Makefile. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@892 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
parent
edad2c6654
commit
f6cfe4e86e
19
Makefile
19
Makefile
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2002-2004 MontaVista Software, Inc.
|
||||
# Copyright (c) 2002-2006 MontaVista Software, Inc.
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
@ -28,25 +28,38 @@
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
# THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# BUILD_DYNAMIC can be defined to 1 to build for dynamic loading of service
|
||||
# handler modules. If the developer intends to debug, building without
|
||||
# dynamic modules should provide an easier route.
|
||||
|
||||
# Production mode flags
|
||||
CFLAGS = -O3 -Wall
|
||||
LDFLAGS = -lpthread
|
||||
LDFLAGS = -lpthread -ldl
|
||||
DESTDIR=/usr/local/openais
|
||||
BUILD_DYNAMIC=1
|
||||
|
||||
# Debug mode flags
|
||||
#CFLAGS = -g -DDEBUG
|
||||
#LDFLAGS = -g
|
||||
#BUILD_DYNAMIC=0
|
||||
|
||||
# Profile mode flags
|
||||
#CFLAGS = -O3 -pg -DDEBUG
|
||||
#LDFLAGS = -pg
|
||||
|
||||
ifeq (${BUILD_DYNAMIC}, 1)
|
||||
CFLAGS += -DBUILD_DYNAMIC=1 -fPIC
|
||||
LDFLAGS += -ldl -rdynamic
|
||||
endif
|
||||
|
||||
all:
|
||||
(cd lcr; echo ==== `pwd` ===; $(MAKE) all CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)");
|
||||
(cd lib; echo ==== `pwd` ===; $(MAKE) all CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)");
|
||||
(cd exec; echo ==== `pwd` ===; $(MAKE) all CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)");
|
||||
(cd exec; echo ==== `pwd` ===; $(MAKE) all CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" BUILD_DYNAMIC="1");
|
||||
(cd test; echo ==== `pwd` ===; $(MAKE) all CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)");
|
||||
|
||||
clean:
|
||||
(cd lcr; echo ==== `pwd` ===; $(MAKE) clean);
|
||||
(cd lib; echo ==== `pwd` ===; $(MAKE) clean);
|
||||
(cd exec; echo ==== `pwd` ===; $(MAKE) clean);
|
||||
(cd test; echo ==== `pwd` ===; $(MAKE) clean);
|
||||
|
130
exec/Makefile
130
exec/Makefile
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2002-2005 MontaVista Software, Inc.
|
||||
# Copyright (c) 2002-2006 MontaVista Software, Inc.
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
@ -28,14 +28,20 @@
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
# THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# BUILD_DYNAMIC can be defined to 1 to build for dynamic loading of service
|
||||
# handler modules. If the developer intends to debug, building without
|
||||
# dynamic modules should provide an easier route.
|
||||
|
||||
# Production mode flags
|
||||
#CFLAGS = -O3 -Wall -fomit-frame-pointer
|
||||
#LDFLAGS = -lpthread
|
||||
#BUILD_DYNAMIC=1
|
||||
|
||||
# Debug mode flags
|
||||
CFLAGS = -g -Wall
|
||||
#-DDEBUG
|
||||
LDFLAGS = -g -lpthread
|
||||
BUILD_DYNAMIC=1
|
||||
|
||||
# Profile mode flags
|
||||
#CFLAGS = -O3 -pg
|
||||
@ -45,18 +51,61 @@ LDFLAGS = -g -lpthread
|
||||
#CFLAGS = -ftest-coverage -fprofile-arcs
|
||||
#LDFLAGS = -g
|
||||
|
||||
TOTEM_SRC = aispoll.c totemip.c totemnet.c totemrrp.c totemsrp.c totemmrp.c totempg.c totemconfig.c tlist.c hdb.c crypto.c wthread.c
|
||||
TOTEM_OBJS = aispoll.o totemip.o totemnet.o totemrrp.o totemsrp.o totemmrp.o totempg.o totemconfig.o tlist.o hdb.o crypto.o wthread.o
|
||||
|
||||
EXEC_SRC = main.c clm.c amf.c ckpt.c evt.c lck.c evs.c print.c mempool.c \
|
||||
util.c sync.c ykd.c cfg.c mainconfig.c amfconfig.o
|
||||
EXEC_OBJS = main.o clm.o amf.o ckpt.o evt.o lck.o evs.o print.o mempool.o \
|
||||
util.o sync.o ykd.o cfg.o mainconfig.o amfconfig.o
|
||||
# Totem objects
|
||||
TOTEM_SRC = aispoll.c totemip.c totemnet.c totemrrp.c totemsrp.c totemmrp.c totempg.c totemconfig.c tlist.c crypto.c wthread.c
|
||||
TOTEM_OBJS = aispoll.o totemip.o totemnet.o totemrrp.o totemsrp.o totemmrp.o totempg.o totemconfig.o tlist.o crypto.o wthread.o
|
||||
EXEC_LIBS = libtotem_pg.a
|
||||
|
||||
OBJS = $(TOTEM_OBJS) $(EXEC_OBJS)
|
||||
# service handler objects
|
||||
SERV_SRC = evs.c clm.c amf.c ckpt.c evt.c lck.c msg.c cfg.c
|
||||
SERV_OBJS = evs.o clm.o amf.o ckpt.o evt.o lck.o msg.o cfg.o
|
||||
|
||||
all:libtotem_pg.a libtotem_pg.so.1.0 aisexec keygen openais-instantiate
|
||||
# main executive objects
|
||||
MAIN_SRC = main.c print.c mempool.c \
|
||||
util.c sync.c ykd.c mainconfig.c amfconfig.o
|
||||
MAIN_OBJS = main.o print.o mempool.o \
|
||||
util.o sync.o ykd.o mainconfig.o amfconfig.o
|
||||
|
||||
ifeq (${BUILD_DYNAMIC}, 1)
|
||||
EXEC_OBJS = $(TOTEM_OBJS) $(MAIN_OBJS)
|
||||
CFLAGS += -DBUILD_DYNAMIC=1 -fPIC
|
||||
LDFLAGS += -ldl -rdynamic
|
||||
EXEC_LIBS += ../lcr/lcr_ifact.o
|
||||
|
||||
all:libtotem_pg.a libtotem_pg.so.1.0 \
|
||||
service_evs.lcrso service_clm.lcrso service_amf.lcrso \
|
||||
service_ckpt.lcrso service_evt.lcrso service_lck.lcrso \
|
||||
service_msg.lcrso service_cfg.lcrso \
|
||||
aisexec keygen openais-instantiate
|
||||
else
|
||||
EXEC_OBJS = $(TOTEM_OBJS) $(MAIN_OBJS) $(SERV_OBJS)
|
||||
all: libtotem_pg.a aisexec keygen openais-instantiate
|
||||
endif
|
||||
|
||||
|
||||
service_evs.lcrso: evs.o
|
||||
$(CC) -shared -Wl,-soname,service_evs.lcrso evs.o -o $@
|
||||
|
||||
service_clm.lcrso: clm.o
|
||||
$(CC) -shared -Wl,-soname,service_clm.lcrso clm.o -o $@
|
||||
|
||||
service_amf.lcrso: amf.o
|
||||
$(CC) -shared -Wl,-soname,service_amf.lcrso amf.o -o $@
|
||||
|
||||
service_ckpt.lcrso: ckpt.o
|
||||
$(CC) -shared -Wl,-soname,service_ckpt.lcrso ckpt.o -o $@
|
||||
|
||||
service_evt.lcrso: evt.o
|
||||
$(CC) -shared -Wl,-soname,service_evt.lcrso evt.o -o $@
|
||||
|
||||
service_lck.lcrso: lck.o
|
||||
$(CC) -shared -Wl,-soname,service_lck.lcrso lck.o -o $@
|
||||
|
||||
service_msg.lcrso: msg.o
|
||||
$(CC) -shared -Wl,-soname,service_msg.lcrso msg.o -o $@
|
||||
|
||||
service_cfg.lcrso: cfg.o
|
||||
$(CC) -shared -Wl,-soname,service_cfg.lcrso cfg.o -o $@
|
||||
|
||||
aisexec: $(EXEC_OBJS) libtotem_pg.a
|
||||
$(CC) $(LDFLAGS) $(EXEC_OBJS) $(EXEC_LIBS) -o aisexec
|
||||
@ -77,11 +126,37 @@ openais-instantiate: openais-instantiate.o
|
||||
$(CC) $(LDFLAGS) openais-instantiate.o -o openais-instantiate
|
||||
|
||||
clean:
|
||||
rm -f aisexec $(OBJS) libtotem_pg.so.1.0 libtotem_pg.so.1 libtotem_pg.so libtotem_pg.a gmon.out keygen keygen.o *.da *.bb *.bbg
|
||||
rm -f aisexec $(OBJS) *.o *.lcrso libtotem_pg.so.1.0 libtotem_pg.so.1 libtotem_pg.so libtotem_pg.a gmon.out keygen keygen.o openais-instantiate *.da *.bb *.bbg
|
||||
|
||||
depend:
|
||||
makedepend -Y -- $(CFLAGS) $(EXEC_SRC) $(TOTEM_SRC) > /dev/null 2>&1
|
||||
|
||||
# - fPIC rules required for service handler shared objects
|
||||
evs.o: evs.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $(*F).c
|
||||
|
||||
clm.o: clm.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $(*F).c
|
||||
|
||||
amf.o: amf.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $(*F).c
|
||||
|
||||
ckpt.o: ckpt.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $(*F).c
|
||||
|
||||
evt.o: evt.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $(*F).c
|
||||
|
||||
lck.o: lck.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $(*F).c
|
||||
|
||||
msg.o: msg.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $(*F).c
|
||||
|
||||
cfg.o: cfg.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $(*F).c
|
||||
|
||||
|
||||
# -fPIC rules required for lib totem
|
||||
aispoll.o: aispoll.c
|
||||
$(CC) $(CFLAGS) -fPIC -c -o $@ $(*F).c
|
||||
@ -107,9 +182,6 @@ wthread.o: wthread.c
|
||||
tlist.o: tlist.c
|
||||
$(CC) $(CFLAGS) -fPIC -c -o $@ $(*F).c
|
||||
|
||||
hdb.o: hdb.c
|
||||
$(CC) $(CFLAGS) -fPIC -c -o $@ $(*F).c
|
||||
|
||||
crypto.o: crypto.c
|
||||
$(CC) $(CFLAGS) -fPIC -c -o $@ $(*F).c
|
||||
|
||||
@ -122,35 +194,35 @@ totemconfig.o: totemconfig.c
|
||||
# DO NOT DELETE
|
||||
|
||||
main.o: ../include/saAis.h ../include/ipc_evs.h ../include/saAis.h
|
||||
main.o: evs.h ../include/saClm.h ../include/ipc_gen.h ../include/list.h
|
||||
main.o: ../include/saClm.h ../include/ipc_gen.h ../include/list.h
|
||||
main.o: ../include/queue.h totempg.h aispoll.h totemsrp.h mempool.h amfconfig.h
|
||||
main.o: main.h clm.h ../include/saClm.h amf.h handlers.h ckpt.h evt.h hdb.h
|
||||
main.o: main.h clm.h ../include/saClm.h amf.h handlers.h ckpt.h evt.h
|
||||
main.o: ../include/saEvt.h swab.h print.h
|
||||
clm.o: ../include/saAis.h ../include/saClm.h ../include/saAis.h
|
||||
clm.o: ../include/ipc_evs.h evs.h ../include/saClm.h ../include/ipc_gen.h
|
||||
clm.o: ../include/ipc_evs.h ../include/saClm.h ../include/ipc_gen.h
|
||||
clm.o: ../include/ipc_clm.h ../include/list.h ../include/queue.h aispoll.h
|
||||
clm.o: totempg.h totemsrp.h amfconfig.h main.h clm.h amf.h handlers.h ckpt.h
|
||||
clm.o: evt.h hdb.h ../include/saEvt.h mempool.h print.h
|
||||
clm.o: evt.h ../include/saEvt.h mempool.h print.h
|
||||
amf.o: ../include/saAis.h ../include/ipc_evs.h ../include/saAis.h
|
||||
amf.o: evs.h ../include/saClm.h ../include/ipc_gen.h ../include/list.h
|
||||
amf.o: ../include/saClm.h ../include/ipc_gen.h ../include/list.h
|
||||
amf.o: ../include/queue.h totempg.h aispoll.h totemsrp.h mempool.h util.h
|
||||
amf.o: amfconfig.h main.h clm.h ../include/saClm.h amf.h handlers.h ckpt.h evt.h
|
||||
amf.o: hdb.h ../include/saEvt.h print.h
|
||||
amf.o: ../include/saEvt.h print.h
|
||||
ckpt.o: ../include/saAis.h ../include/ipc_evs.h ../include/saAis.h
|
||||
ckpt.o: evs.h ../include/saClm.h ../include/ipc_gen.h ../include/list.h
|
||||
ckpt.o: ../include/saClm.h ../include/ipc_gen.h ../include/list.h
|
||||
ckpt.o: ../include/queue.h aispoll.h mempool.h util.h amfconfig.h totempg.h
|
||||
ckpt.o: totemsrp.h main.h clm.h ../include/saClm.h amf.h handlers.h ckpt.h
|
||||
ckpt.o: evt.h hdb.h ../include/saEvt.h print.h
|
||||
ckpt.o: evt.h ../include/saEvt.h print.h
|
||||
evt.o: ../include/ipc_evt.h ../include/saAis.h ../include/saEvt.h
|
||||
evt.o: ../include/saClm.h ../include/ipc_gen.h ../include/list.h
|
||||
evt.o: ../include/queue.h util.h ../include/saAis.h aispoll.h mempool.h
|
||||
evt.o: amfconfig.h totempg.h totemsrp.h main.h evs.h clm.h ../include/saClm.h
|
||||
evt.o: amf.h ../include/ipc_evs.h handlers.h ckpt.h evt.h hdb.h
|
||||
evt.o: amfconfig.h totempg.h totemsrp.h main.h clm.h ../include/saClm.h
|
||||
evt.o: amf.h ../include/ipc_evs.h handlers.h ckpt.h evt.h
|
||||
evt.o: ../include/saEvt.h swab.h print.h
|
||||
evs.o: ../include/saAis.h ../include/ipc_evs.h ../include/saAis.h
|
||||
evs.o: evs.h ../include/saClm.h ../include/ipc_gen.h ../include/list.h
|
||||
evs.o: ../include/saClm.h ../include/ipc_gen.h ../include/list.h
|
||||
evs.o: ../include/queue.h aispoll.h totempg.h totemsrp.h amfconfig.h main.h clm.h
|
||||
evs.o: ../include/saClm.h amf.h handlers.h ckpt.h evt.h hdb.h
|
||||
evs.o: ../include/saClm.h amf.h handlers.h ckpt.h evt.h
|
||||
evs.o: ../include/saEvt.h mempool.h print.h
|
||||
amfconfig.o: ../include/saAis.h ../include/list.h util.h amfconfig.h aispoll.h
|
||||
amfconfig.o: totempg.h totemsrp.h mempool.h print.h ../include/saClm.h
|
||||
@ -160,10 +232,10 @@ print.o: ../include/saAis.h amfconfig.h ../include/list.h aispoll.h totempg.h
|
||||
print.o: totemsrp.h
|
||||
mempool.o: ../include/list.h mempool.h
|
||||
util.o: ../include/saAis.h ../include/list.h util.h
|
||||
aispoll.o: aispoll.h ../include/list.h hdb.h ../include/saAis.h tlist.h
|
||||
aispoll.o: aispoll.h ../include/list.h ../include/saAis.h tlist.h
|
||||
totemsrp.o: aispoll.h totemsrp.h ../include/queue.h ../include/sq.h
|
||||
totemsrp.o: ../include/list.h hdb.h ../include/saAis.h swab.h crypto.h
|
||||
totemsrp.o: ../include/list.h ../include/saAis.h swab.h crypto.h
|
||||
totempg.o: totempg.h aispoll.h totemsrp.h swab.h
|
||||
tlist.o: ../include/list.h tlist.h
|
||||
hdb.o: hdb.h ../include/saAis.h
|
||||
hdb.o: ../include/saAis.h
|
||||
crypto.o: crypto.h
|
||||
|
@ -40,8 +40,7 @@
|
||||
|
||||
#include "aispoll.h"
|
||||
#include "../include/list.h"
|
||||
#include "hdb.h"
|
||||
#include "../include/saAis.h"
|
||||
#include "../include/hdb.h"
|
||||
#include "tlist.h"
|
||||
|
||||
typedef int (*dispatch_fn_t) (poll_handle poll_handle, int fd, int revents, void *data, unsigned int *prio);
|
||||
@ -63,26 +62,26 @@ struct poll_instance {
|
||||
/*
|
||||
* All instances in one database
|
||||
*/
|
||||
static struct saHandleDatabase poll_instance_database = {
|
||||
.handleCount = 0,
|
||||
.handles = 0,
|
||||
.handleInstanceDestructor = 0
|
||||
static struct hdb_handle_database poll_instance_database = {
|
||||
.handle_count = 0,
|
||||
.handles = 0,
|
||||
.iterator = 0
|
||||
};
|
||||
|
||||
poll_handle poll_create (void)
|
||||
{
|
||||
poll_handle handle;
|
||||
struct poll_instance *poll_instance;
|
||||
SaErrorT error;
|
||||
unsigned int res;
|
||||
|
||||
error = saHandleCreate (&poll_instance_database,
|
||||
res = hdb_handle_create (&poll_instance_database,
|
||||
sizeof (struct poll_instance), &handle);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_exit;
|
||||
}
|
||||
error = saHandleInstanceGet (&poll_instance_database, handle,
|
||||
res = hdb_handle_get (&poll_instance_database, handle,
|
||||
(void *)&poll_instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_destroy;
|
||||
}
|
||||
|
||||
@ -94,7 +93,7 @@ poll_handle poll_create (void)
|
||||
return (handle);
|
||||
|
||||
error_destroy:
|
||||
saHandleDestroy (&poll_instance_database, handle);
|
||||
hdb_handle_destroy (&poll_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (-1);
|
||||
@ -103,12 +102,11 @@ error_exit:
|
||||
int poll_destroy (poll_handle handle)
|
||||
{
|
||||
struct poll_instance *poll_instance;
|
||||
SaErrorT error;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&poll_instance_database, handle,
|
||||
res = hdb_handle_get (&poll_instance_database, handle,
|
||||
(void *)&poll_instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = -ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
@ -121,9 +119,9 @@ int poll_destroy (poll_handle handle)
|
||||
}
|
||||
timerlist_free (&poll_instance->timerlist);
|
||||
|
||||
saHandleDestroy (&poll_instance_database, handle);
|
||||
hdb_handle_destroy (&poll_instance_database, handle);
|
||||
|
||||
saHandleInstancePut (&poll_instance_database, handle);
|
||||
hdb_handle_put (&poll_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (res);
|
||||
@ -142,12 +140,11 @@ int poll_dispatch_add (
|
||||
struct pollfd *ufds;
|
||||
int found = 0;
|
||||
int install_pos;
|
||||
SaErrorT error;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&poll_instance_database, handle,
|
||||
res = hdb_handle_get (&poll_instance_database, handle,
|
||||
(void *)&poll_instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = -ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
@ -196,7 +193,7 @@ int poll_dispatch_add (
|
||||
poll_instance->poll_entries[install_pos].data = data;
|
||||
|
||||
error_put:
|
||||
saHandleInstancePut (&poll_instance_database, handle);
|
||||
hdb_handle_put (&poll_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (res);
|
||||
@ -211,12 +208,11 @@ int poll_dispatch_modify (
|
||||
{
|
||||
struct poll_instance *poll_instance;
|
||||
int i;
|
||||
SaErrorT error;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&poll_instance_database, handle,
|
||||
res = hdb_handle_get (&poll_instance_database, handle,
|
||||
(void *)&poll_instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = -ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
@ -237,7 +233,7 @@ int poll_dispatch_modify (
|
||||
res = -EBADF;
|
||||
|
||||
error_put:
|
||||
saHandleInstancePut (&poll_instance_database, handle);
|
||||
hdb_handle_put (&poll_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (res);
|
||||
@ -249,13 +245,12 @@ int poll_dispatch_delete (
|
||||
{
|
||||
struct poll_instance *poll_instance;
|
||||
int i;
|
||||
SaErrorT error;
|
||||
int found = 0;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&poll_instance_database, handle,
|
||||
res = hdb_handle_get (&poll_instance_database, handle,
|
||||
(void *)&poll_instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = -ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
@ -290,7 +285,7 @@ int poll_dispatch_delete (
|
||||
}
|
||||
|
||||
|
||||
saHandleInstancePut (&poll_instance_database, handle);
|
||||
hdb_handle_put (&poll_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (res);
|
||||
@ -304,11 +299,10 @@ int poll_timer_add (
|
||||
{
|
||||
struct poll_instance *poll_instance;
|
||||
int res = 0;
|
||||
SaErrorT error;
|
||||
|
||||
error = saHandleInstanceGet (&poll_instance_database, handle,
|
||||
res = hdb_handle_get (&poll_instance_database, handle,
|
||||
(void *)&poll_instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = -ENOENT;
|
||||
|
||||
goto error_exit;
|
||||
@ -321,7 +315,7 @@ int poll_timer_add (
|
||||
res = -ENOENT;
|
||||
}
|
||||
|
||||
saHandleInstancePut (&poll_instance_database, handle);
|
||||
hdb_handle_put (&poll_instance_database, handle);
|
||||
error_exit:
|
||||
return (res);
|
||||
}
|
||||
@ -331,22 +325,21 @@ int poll_timer_delete (
|
||||
poll_timer_handle timer_handle)
|
||||
{
|
||||
struct poll_instance *poll_instance;
|
||||
SaErrorT error;
|
||||
int res = 0;
|
||||
|
||||
if (timer_handle == 0) {
|
||||
return (0);
|
||||
}
|
||||
error = saHandleInstanceGet (&poll_instance_database, handle,
|
||||
res = hdb_handle_get (&poll_instance_database, handle,
|
||||
(void *)&poll_instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = -ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
timerlist_del (&poll_instance->timerlist, (void *)timer_handle);
|
||||
|
||||
saHandleInstancePut (&poll_instance_database, handle);
|
||||
hdb_handle_put (&poll_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (res);
|
||||
@ -356,22 +349,21 @@ int poll_timer_delete_data (
|
||||
poll_handle handle,
|
||||
poll_timer_handle timer_handle) {
|
||||
struct poll_instance *poll_instance;
|
||||
SaErrorT error;
|
||||
int res = 0;
|
||||
|
||||
if (timer_handle == 0) {
|
||||
return (0);
|
||||
}
|
||||
error = saHandleInstanceGet (&poll_instance_database, handle,
|
||||
res = hdb_handle_get (&poll_instance_database, handle,
|
||||
(void *)&poll_instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = -ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
timerlist_del_data (&poll_instance->timerlist, (void *)timer_handle);
|
||||
|
||||
saHandleInstancePut (&poll_instance_database, handle);
|
||||
hdb_handle_put (&poll_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (res);
|
||||
@ -392,12 +384,11 @@ int poll_run (
|
||||
int i;
|
||||
int timeout = -1;
|
||||
int res;
|
||||
SaErrorT error;
|
||||
int poll_entry_count;
|
||||
|
||||
error = saHandleInstanceGet (&poll_instance_database, handle,
|
||||
res = hdb_handle_get (&poll_instance_database, handle,
|
||||
(void *)&poll_instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
@ -447,7 +438,7 @@ retry_poll:
|
||||
timerlist_expire (&poll_instance->timerlist);
|
||||
} /* for (;;) */
|
||||
|
||||
saHandleInstancePut (&poll_instance_database, handle);
|
||||
hdb_handle_put (&poll_instance_database, handle);
|
||||
error_exit:
|
||||
return (-1);
|
||||
}
|
||||
@ -462,11 +453,10 @@ void poll_print_state (
|
||||
{
|
||||
struct poll_instance *poll_instance;
|
||||
int i;
|
||||
SaErrorT error;
|
||||
int res = 0;
|
||||
error = saHandleInstanceGet (&poll_instance_database, handle,
|
||||
res = hdb_handle_get (&poll_instance_database, handle,
|
||||
(void *)&poll_instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = -ENOENT;
|
||||
exit (1);
|
||||
}
|
||||
|
86
exec/amf.c
86
exec/amf.c
@ -1,6 +1,6 @@
|
||||
int waiting = 0;
|
||||
/*
|
||||
* Copyright (c) 2002-2005 MontaVista Software, Inc.
|
||||
* Copyright (c) 2002-2006 MontaVista Software, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -56,6 +56,7 @@ int waiting = 0;
|
||||
#include "../include/ipc_amf.h"
|
||||
#include "../include/list.h"
|
||||
#include "../include/queue.h"
|
||||
#include "../lcr/lcr_comp.h"
|
||||
#include "totempg.h"
|
||||
#include "aispoll.h"
|
||||
#include "mempool.h"
|
||||
@ -70,6 +71,13 @@ int waiting = 0;
|
||||
#define LOG_LEVEL_FROM_GMI LOG_LEVEL_DEBUG
|
||||
#define LOG_LEVEL_ENTER_FUNC LOG_LEVEL_DEBUG
|
||||
|
||||
enum amf_message_req_types {
|
||||
MESSAGE_REQ_EXEC_AMF_OPERATIONAL_STATE_COMP_SET = 0,
|
||||
MESSAGE_REQ_EXEC_AMF_PRESENCE_STATE_COMP_SET = 1,
|
||||
MESSAGE_REQ_EXEC_AMF_ADMINISTRATIVE_STATE_CSI_SET = 2,
|
||||
MESSAGE_REQ_EXEC_AMF_ADMINISTRATIVE_STATE_UNIT_SET = 3,
|
||||
MESSAGE_REQ_EXEC_AMF_ADMINISTRATIVE_STATE_GROUP_SET = 4
|
||||
};
|
||||
|
||||
struct invocation {
|
||||
void *data;
|
||||
@ -362,6 +370,8 @@ int (*amf_aisexec_handler_fns[]) (
|
||||
* Exports the interface for the service
|
||||
*/
|
||||
struct service_handler amf_service_handler = {
|
||||
.name = "openais availability management framework B.01.01",
|
||||
.id = AMF_SERVICE,
|
||||
.libais_handlers = amf_libais_handlers,
|
||||
.libais_handlers_count = sizeof (amf_libais_handlers) / sizeof (struct libais_handler),
|
||||
.aisexec_handler_fns = amf_aisexec_handler_fns,
|
||||
@ -372,6 +382,46 @@ struct service_handler amf_service_handler = {
|
||||
.exec_init_fn = amf_exec_init_fn,
|
||||
};
|
||||
|
||||
#ifdef BUILD_DYNAMIC
|
||||
|
||||
struct service_handler *amf_get_handler_ver0 (void);
|
||||
|
||||
struct aisexec_iface_ver0 amf_service_handler_iface = {
|
||||
.test = NULL,
|
||||
.get_handler_ver0 = amf_get_handler_ver0
|
||||
};
|
||||
|
||||
struct lcr_iface openais_amf_ver0[1] = {
|
||||
{
|
||||
.name = "openais_amf",
|
||||
.version = 0,
|
||||
.versions_replace = 0,
|
||||
.versions_replace_count = 0,
|
||||
.dependencies = 0,
|
||||
.dependency_count = 0,
|
||||
.constructor = NULL,
|
||||
.destructor = NULL,
|
||||
.interfaces = (void **)&amf_service_handler_iface,
|
||||
}
|
||||
};
|
||||
|
||||
struct lcr_comp amf_comp_ver0 = {
|
||||
.iface_count = 1,
|
||||
.ifaces = openais_amf_ver0
|
||||
};
|
||||
|
||||
extern int lcr_comp_get (struct lcr_comp **component)
|
||||
{
|
||||
*component = &amf_comp_ver0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
struct service_handler *amf_get_handler_ver0 (void)
|
||||
{
|
||||
return (&amf_service_handler);
|
||||
}
|
||||
#endif /* BUILD_DYNAMIC */
|
||||
|
||||
enum clc_command_run_operation_type {
|
||||
CLC_COMMAND_RUN_OPERATION_TYPE_INSTANTIATE = 1,
|
||||
CLC_COMMAND_RUN_OPERATION_TYPE_TERMINATE = 2,
|
||||
@ -1138,7 +1188,8 @@ static void error_report (struct amf_comp *comp)
|
||||
struct iovec iovec;
|
||||
|
||||
req_exec_amf_error_report.header.size = sizeof (struct req_exec_amf_error_report);
|
||||
req_exec_amf_error_report.header.id = MESSAGE_REQ_EXEC_AMF_ERROR_REPORT;
|
||||
req_exec_amf_error_report.header.id =
|
||||
SERVICE_ID_MAKE (AMF_SERVICE, MESSAGE_REQ_EXEC_AMF_ERROR_REPORT);
|
||||
memcpy (&req_exec_amf_error_report.compName,
|
||||
&comp->name,
|
||||
sizeof (SaNameT));
|
||||
@ -1156,7 +1207,8 @@ static void TODO_COMP_RESTART_THISISADEADPLACEHOLDER (struct amf_comp *comp)
|
||||
struct iovec iovec;
|
||||
|
||||
req_exec_amf_comp_restart.header.size = sizeof (struct req_exec_amf_comp_restart);
|
||||
req_exec_amf_comp_restart.header.id = MESSAGE_REQ_EXEC_AMF_UNIT_RESTART;
|
||||
req_exec_amf_comp_restart.header.id =
|
||||
SERVICE_ID_MAKE (AMF_SERVICE, MESSAGE_REQ_EXEC_AMF_UNIT_RESTART);
|
||||
memcpy (&req_exec_amf_comp_restart.compName, &comp->name,
|
||||
sizeof (SaNameT));
|
||||
|
||||
@ -1248,7 +1300,8 @@ void presence_state_comp_set (
|
||||
struct iovec iovec;
|
||||
|
||||
req_exec_amf_presence_state_comp_set.header.size = sizeof (struct req_exec_amf_presence_state_comp_set);
|
||||
req_exec_amf_presence_state_comp_set.header.id = MESSAGE_REQ_EXEC_AMF_PRESENCE_STATE_COMP_SET;
|
||||
req_exec_amf_presence_state_comp_set.header.id =
|
||||
SERVICE_ID_MAKE (AMF_SERVICE, MESSAGE_REQ_EXEC_AMF_PRESENCE_STATE_COMP_SET);
|
||||
req_exec_amf_presence_state_comp_set.presence_state = presence_state;
|
||||
memcpy (&req_exec_amf_presence_state_comp_set.name,
|
||||
&comp->name,
|
||||
@ -1291,6 +1344,7 @@ void operational_state_comp_set (struct amf_comp *comp, OpenaisCfgOperationalSta
|
||||
|
||||
req_exec_amf_operational_state_comp_set.header.size = sizeof (struct req_exec_amf_operational_state_comp_set);
|
||||
req_exec_amf_operational_state_comp_set.header.id = MESSAGE_REQ_EXEC_AMF_OPERATIONAL_STATE_COMP_SET;
|
||||
SERVICE_ID_MAKE (AMF_SERVICE, MESSAGE_REQ_EXEC_AMF_OPERATIONAL_STATE_COMP_SET);
|
||||
req_exec_amf_operational_state_comp_set.operational_state = operational_state;
|
||||
memcpy (&req_exec_amf_operational_state_comp_set.name,
|
||||
&comp->name,
|
||||
@ -2375,7 +2429,8 @@ static int message_handler_req_lib_amf_componentunregister (struct conn_info *co
|
||||
log_printf (LOG_LEVEL_FROM_LIB, "Handle : message_handler_req_lib_amf_componentunregister()\n");
|
||||
|
||||
req_exec_amf_componentunregister.header.size = sizeof (struct req_exec_amf_componentunregister);
|
||||
req_exec_amf_componentunregister.header.id = MESSAGE_REQ_EXEC_AMF_COMPONENTUNREGISTER;
|
||||
req_exec_amf_componentunregister.header.id =
|
||||
SERVICE_ID_MAKE (AMF_SERVICE, MESSAGE_REQ_EXEC_AMF_COMPONENTUNREGISTER);
|
||||
|
||||
message_source_set (&req_exec_amf_componentunregister.source, conn_info);
|
||||
|
||||
@ -2714,7 +2769,8 @@ static int message_handler_req_lib_amf_componenterrorclear (struct conn_info *co
|
||||
log_printf (LOG_LEVEL_FROM_LIB, "Handle : message_handler_req_lib_amf_componenterrorclear()\n");
|
||||
|
||||
req_exec_amf_componenterrorclear.header.size = sizeof (struct req_exec_amf_componenterrorclear);
|
||||
req_exec_amf_componenterrorclear.header.id = MESSAGE_REQ_EXEC_AMF_COMPONENTERRORCLEAR;
|
||||
req_exec_amf_componenterrorclear.header.id =
|
||||
SERVICE_ID_MAKE (AMF_SERVICE, MESSAGE_REQ_EXEC_AMF_COMPONENTERRORCLEAR);
|
||||
|
||||
message_source_set (&req_exec_amf_componenterrorclear.source, conn_info);
|
||||
|
||||
@ -3151,7 +3207,8 @@ static void component_unregister (
|
||||
component->probableCause = SA_AMF_NOT_RESPONDING;
|
||||
|
||||
req_exec_amf_componentunregister.header.size = sizeof (struct req_exec_amf_componentunregister);
|
||||
req_exec_amf_componentunregister.header.id = MESSAGE_REQ_EXEC_AMF_COMPONENTUNREGISTER;
|
||||
req_exec_amf_componentunregister.header.id =
|
||||
SERVICE_ID_MAKE (AMF_SERVICE, MESSAGE_REQ_EXEC_AMF_COMPONENTUNREGISTER);
|
||||
|
||||
req_exec_amf_componentunregister.source.conn_info = 0;
|
||||
req_exec_amf_componentunregister.source.in_addr.s_addr = 0;
|
||||
@ -3184,7 +3241,8 @@ static void component_register (
|
||||
getSaNameT (&component->name));
|
||||
|
||||
req_exec_amf_componentregister.header.size = sizeof (struct req_exec_amf_componentregister);
|
||||
req_exec_amf_componentregister.header.id = MESSAGE_REQ_EXEC_AMF_COMPONENTREGISTER;
|
||||
req_exec_amf_componentregister.header.id =
|
||||
SERVICE_ID_MAKE (AMF_SERVICE, MESSAGE_REQ_EXEC_AMF_COMPONENTREGISTER);
|
||||
|
||||
req_exec_amf_componentregister.source.conn_info = 0;
|
||||
req_exec_amf_componentregister.source.in_addr.s_addr = 0;
|
||||
@ -3310,7 +3368,8 @@ static void ha_state_group_set (
|
||||
struct req_exec_amf_hastateset req_exec_amf_hastateset;
|
||||
struct iovec iovec;
|
||||
|
||||
req_exec_amf_hastateset.header.id = MESSAGE_REQ_EXEC_AMF_HASTATESET;
|
||||
req_exec_amf_hastateset.header.id =
|
||||
SERVICE_ID_MAKE (AMF_SERVICE, MESSAGE_REQ_EXEC_AMF_HASTATESET);
|
||||
req_exec_amf_hastateset.header.size = sizeof (struct req_exec_amf_hastateset);
|
||||
memcpy (&req_exec_amf_hastateset.compName, &component->name, sizeof (SaNameT));
|
||||
req_exec_amf_hastateset.haState = haState;
|
||||
@ -3378,7 +3437,8 @@ static void readiness_state_group_set (
|
||||
struct req_exec_amf_readinessstateset req_exec_amf_readinessstateset;
|
||||
struct iovec iovec;
|
||||
|
||||
req_exec_amf_readinessstateset.header.id = MESSAGE_REQ_EXEC_AMF_READINESSSTATESET;
|
||||
req_exec_amf_readinessstateset.header.id =
|
||||
SERVICE_ID_MAKE (AMF_SERVICE, MESSAGE_REQ_EXEC_AMF_READINESSSTATESET);
|
||||
req_exec_amf_readinessstateset.header.size = sizeof (struct req_exec_amf_readinessstateset);
|
||||
memcpy (&req_exec_amf_readinessstateset.compName, &component->name, sizeof (SaNameT));
|
||||
req_exec_amf_readinessstateset.readinessState = readinessState;
|
||||
@ -3977,7 +4037,8 @@ void error_report (
|
||||
struct iovec iovec;
|
||||
|
||||
req_exec_amf_componenterrorreport.header.size = sizeof (struct req_exec_amf_componenterrorreport);
|
||||
req_exec_amf_componenterrorreport.header.id = MESSAGE_REQ_EXEC_AMF_ERRORREPORT;
|
||||
req_exec_amf_componenterrorreport.header.id =
|
||||
SERVICE_ID_MAKE (AMF_SERVICE, MESSAGE_REQ_EXEC_AMF_ERRORREPORT);
|
||||
|
||||
req_exec_amf_componenterrorreport.source.conn_info = 0;
|
||||
req_exec_amf_componenterrorreport.source.in_addr.s_addr = 0;
|
||||
@ -4270,7 +4331,8 @@ static int message_handler_req_lib_amf_readinessstateget (struct conn_info *conn
|
||||
log_printf (LOG_LEVEL_FROM_LIB, "Handle : message_handler_req_amf_componentregister()\n");
|
||||
|
||||
req_exec_amf_componentregister.header.size = sizeof (struct req_exec_amf_componentregister);
|
||||
req_exec_amf_componentregister.header.id = MESSAGE_REQ_EXEC_AMF_COMPONENTREGISTER;
|
||||
req_exec_amf_componentregister.header.id =
|
||||
SERVICE_ID_MAKE (AMF_SERVICE, MESSAGE_REQ_EXEC_AMF_COMPONENTREGISTER);
|
||||
|
||||
message_source_set (&req_exec_amf_componentregister.source, conn_info);
|
||||
|
||||
|
44
exec/cfg.c
44
exec/cfg.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005 MontaVista Software, Inc.
|
||||
* Copyright (c) 2005-2006 MontaVista Software, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -51,6 +51,7 @@
|
||||
#include "../include/ipc_cfg.h"
|
||||
#include "../include/list.h"
|
||||
#include "../include/queue.h"
|
||||
#include "../lcr/lcr_comp.h"
|
||||
#include "totempg.h"
|
||||
#include "aispoll.h"
|
||||
#include "mempool.h"
|
||||
@ -128,6 +129,8 @@ int (*cfg_aisexec_handler_fns[]) (void *, struct in_addr source_addr, int endian
|
||||
* Exports the interface for the service
|
||||
*/
|
||||
struct service_handler cfg_service_handler = {
|
||||
.name = "openais configuration service",
|
||||
.id = CFG_SERVICE,
|
||||
.libais_handlers = cfg_libais_handlers,
|
||||
.libais_handlers_count = sizeof (cfg_libais_handlers) / sizeof (struct libais_handler),
|
||||
.aisexec_handler_fns = cfg_aisexec_handler_fns,
|
||||
@ -138,6 +141,45 @@ struct service_handler cfg_service_handler = {
|
||||
.exec_init_fn = cfg_exec_init_fn,
|
||||
};
|
||||
|
||||
#ifdef BUILD_DYNAMIC
|
||||
|
||||
struct service_handler *cfg_get_handler_ver0 (void);
|
||||
|
||||
struct aisexec_iface_ver0 cfg_service_handler_iface = {
|
||||
.test = NULL,
|
||||
.get_handler_ver0 = cfg_get_handler_ver0
|
||||
};
|
||||
|
||||
struct lcr_iface openais_cfg_ver0[1] = {
|
||||
{
|
||||
.name = "openais_cfg",
|
||||
.version = 0,
|
||||
.versions_replace = 0,
|
||||
.versions_replace_count = 0,
|
||||
.dependencies = 0,
|
||||
.dependency_count = 0,
|
||||
.constructor = NULL,
|
||||
.destructor = NULL,
|
||||
.interfaces = (void **)&cfg_service_handler_iface,
|
||||
}
|
||||
};
|
||||
|
||||
struct lcr_comp cfg_comp_ver0 = {
|
||||
.iface_count = 1,
|
||||
.ifaces = openais_cfg_ver0
|
||||
};
|
||||
|
||||
extern int lcr_comp_get (struct lcr_comp **component)
|
||||
{
|
||||
*component = &cfg_comp_ver0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
struct service_handler *cfg_get_handler_ver0 (void)
|
||||
{
|
||||
return (&cfg_service_handler);
|
||||
}
|
||||
#endif /* BUILD_DYNAMIC */
|
||||
/* IMPL */
|
||||
|
||||
static int cfg_exec_init_fn (struct openais_config *openais_config)
|
||||
|
122
exec/ckpt.c
122
exec/ckpt.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2004 MontaVista Software, Inc.
|
||||
* Copyright (c) 2003-2006 MontaVista Software, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -50,6 +50,7 @@
|
||||
#include "../include/ipc_ckpt.h"
|
||||
#include "../include/list.h"
|
||||
#include "../include/queue.h"
|
||||
#include "../lcr/lcr_comp.h"
|
||||
#include "aispoll.h"
|
||||
#include "mempool.h"
|
||||
#include "util.h"
|
||||
@ -60,6 +61,22 @@
|
||||
#define CKPT_MAX_SECTION_DATA_SEND (1024*400)
|
||||
#include "print.h"
|
||||
|
||||
enum ckpt_message_req_types {
|
||||
MESSAGE_REQ_EXEC_CKPT_CHECKPOINTOPEN = 0,
|
||||
MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE = 1,
|
||||
MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK = 2,
|
||||
MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONSET = 3,
|
||||
MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONEXPIRE = 4,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONCREATE = 5,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONDELETE = 6,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONEXPIRATIONTIMESET = 7,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONWRITE = 8,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONOVERWRITE = 9,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONREAD = 10,
|
||||
MESSAGE_REQ_EXEC_CKPT_SYNCHRONIZESTATE = 11,
|
||||
MESSAGE_REQ_EXEC_CKPT_SYNCHRONIZESECTION = 12
|
||||
};
|
||||
|
||||
struct ckpt_identifier {
|
||||
SaNameT ckpt_name;
|
||||
SaCkptSectionIdT ckpt_section_id;
|
||||
@ -327,6 +344,8 @@ static int (*ckpt_aisexec_handler_fns[]) (void *msg, struct totem_ip_address *so
|
||||
};
|
||||
|
||||
struct service_handler ckpt_service_handler = {
|
||||
.name = "openais checkpoint service B.01.01",
|
||||
.id = CKPT_SERVICE,
|
||||
.libais_handlers = ckpt_libais_handlers,
|
||||
.libais_handlers_count = sizeof (ckpt_libais_handlers) / sizeof (struct libais_handler),
|
||||
.aisexec_handler_fns = ckpt_aisexec_handler_fns,
|
||||
@ -342,6 +361,46 @@ struct service_handler ckpt_service_handler = {
|
||||
.sync_abort = ckpt_recovery_abort,
|
||||
};
|
||||
|
||||
#ifdef BUILD_DYNAMIC
|
||||
|
||||
struct service_handler *ckpt_get_handler_ver0 (void);
|
||||
|
||||
struct aisexec_iface_ver0 ckpt_service_handler_iface = {
|
||||
.test = NULL,
|
||||
.get_handler_ver0 = ckpt_get_handler_ver0
|
||||
};
|
||||
|
||||
struct lcr_iface openais_ckpt_ver0[1] = {
|
||||
{
|
||||
.name = "openais_ckpt",
|
||||
.version = 0,
|
||||
.versions_replace = 0,
|
||||
.versions_replace_count = 0,
|
||||
.dependencies = 0,
|
||||
.dependency_count = 0,
|
||||
.constructor = NULL,
|
||||
.destructor = NULL,
|
||||
.interfaces = (void **)&ckpt_service_handler_iface,
|
||||
}
|
||||
};
|
||||
|
||||
struct lcr_comp ckpt_comp_ver0 = {
|
||||
.iface_count = 1,
|
||||
.ifaces = openais_ckpt_ver0
|
||||
};
|
||||
|
||||
extern int lcr_comp_get (struct lcr_comp **component)
|
||||
{
|
||||
*component = &ckpt_comp_ver0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
struct service_handler *ckpt_get_handler_ver0 (void)
|
||||
{
|
||||
return (&ckpt_service_handler);
|
||||
}
|
||||
#endif /* BUILD_DYNAMIC */
|
||||
|
||||
/*
|
||||
* All data types used for executive messages
|
||||
*/
|
||||
@ -711,7 +770,9 @@ static int ckpt_recovery_process (void)
|
||||
(char*)&checkpoint->name.value);
|
||||
}
|
||||
request_exec_sync_state.header.size = sizeof (struct req_exec_ckpt_synchronize_state);
|
||||
request_exec_sync_state.header.id = MESSAGE_REQ_EXEC_CKPT_SYNCHRONIZESTATE;
|
||||
request_exec_sync_state.header.id =
|
||||
SERVICE_ID_MAKE (CKPT_SERVICE,
|
||||
MESSAGE_REQ_EXEC_CKPT_SYNCHRONIZESTATE);
|
||||
memcpy(&request_exec_sync_state.previous_ring_id, &saved_ring_id, sizeof(struct memb_ring_id));
|
||||
memcpy(&request_exec_sync_state.checkpointName, &checkpoint->name, sizeof(SaNameT));
|
||||
memcpy(&request_exec_sync_state.checkpointCreationAttributes,
|
||||
@ -788,7 +849,9 @@ static int ckpt_recovery_process (void)
|
||||
*/
|
||||
|
||||
request_exec_sync_section.header.size = sizeof (struct req_exec_ckpt_synchronize_section);
|
||||
request_exec_sync_section.header.id = MESSAGE_REQ_EXEC_CKPT_SYNCHRONIZESECTION;
|
||||
request_exec_sync_section.header.id =
|
||||
SERVICE_ID_MAKE (CKPT_SERVICE,
|
||||
MESSAGE_REQ_EXEC_CKPT_SYNCHRONIZESECTION);
|
||||
memcpy (&request_exec_sync_section.previous_ring_id, &saved_ring_id, sizeof(struct memb_ring_id));
|
||||
memcpy (&request_exec_sync_section.checkpointName, &checkpoint->name, sizeof(SaNameT));
|
||||
memcpy (&request_exec_sync_section.sectionId,
|
||||
@ -1276,7 +1339,9 @@ int ckpt_checkpoint_close (struct saCkptCheckpoint *checkpoint) {
|
||||
}
|
||||
req_exec_ckpt_checkpointclose.header.size =
|
||||
sizeof (struct req_exec_ckpt_checkpointclose);
|
||||
req_exec_ckpt_checkpointclose.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE;
|
||||
req_exec_ckpt_checkpointclose.header.id =
|
||||
SERVICE_ID_MAKE (CKPT_SERVICE,
|
||||
MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE);
|
||||
|
||||
memcpy (&req_exec_ckpt_checkpointclose.checkpointName,
|
||||
&checkpoint->name, sizeof (SaNameT));
|
||||
@ -1824,7 +1889,9 @@ void timer_function_retention (void *data)
|
||||
checkpoint->retention_timer = 0;
|
||||
req_exec_ckpt_checkpointretentiondurationexpire.header.size =
|
||||
sizeof (struct req_exec_ckpt_checkpointretentiondurationexpire);
|
||||
req_exec_ckpt_checkpointretentiondurationexpire.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONEXPIRE;
|
||||
req_exec_ckpt_checkpointretentiondurationexpire.header.id =
|
||||
SERVICE_ID_MAKE (CKPT_SERVICE,
|
||||
MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONEXPIRE);
|
||||
|
||||
memcpy (&req_exec_ckpt_checkpointretentiondurationexpire.checkpointName,
|
||||
&checkpoint->name,
|
||||
@ -2009,7 +2076,9 @@ static int message_handler_req_exec_ckpt_checkpointretentiondurationexpire (void
|
||||
|
||||
req_exec_ckpt_checkpointunlink.header.size =
|
||||
sizeof (struct req_exec_ckpt_checkpointunlink);
|
||||
req_exec_ckpt_checkpointunlink.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK;
|
||||
req_exec_ckpt_checkpointunlink.header.id =
|
||||
SERVICE_ID_MAKE (CKPT_SERVICE,
|
||||
MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK);
|
||||
|
||||
req_exec_ckpt_checkpointunlink.source.conn_info = 0;
|
||||
req_exec_ckpt_checkpointunlink.source.addr.family = 0;
|
||||
@ -2786,7 +2855,8 @@ static int message_handler_req_lib_ckpt_checkpointopen (struct conn_info *conn_i
|
||||
log_printf (LOG_LEVEL_DEBUG, "Library request to open checkpoint.\n");
|
||||
req_exec_ckpt_checkpointopen.header.size =
|
||||
sizeof (struct req_exec_ckpt_checkpointopen);
|
||||
req_exec_ckpt_checkpointopen.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTOPEN;
|
||||
req_exec_ckpt_checkpointopen.header.id =
|
||||
SERVICE_ID_MAKE (CKPT_SERVICE, MESSAGE_REQ_EXEC_CKPT_CHECKPOINTOPEN);
|
||||
|
||||
message_source_set (&req_exec_ckpt_checkpointopen.source, conn_info);
|
||||
|
||||
@ -2816,7 +2886,8 @@ static int message_handler_req_lib_ckpt_checkpointopenasync (struct conn_info *c
|
||||
log_printf (LOG_LEVEL_DEBUG, "Library request to open checkpoint async.\n");
|
||||
req_exec_ckpt_checkpointopen.header.size =
|
||||
sizeof (struct req_exec_ckpt_checkpointopen);
|
||||
req_exec_ckpt_checkpointopen.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTOPEN;
|
||||
req_exec_ckpt_checkpointopen.header.id =
|
||||
SERVICE_ID_MAKE (CKPT_SERVICE, MESSAGE_REQ_EXEC_CKPT_CHECKPOINTOPEN);
|
||||
|
||||
message_source_set (&req_exec_ckpt_checkpointopen.source, conn_info);
|
||||
|
||||
@ -2849,7 +2920,9 @@ static int message_handler_req_lib_ckpt_checkpointclose (struct conn_info *conn_
|
||||
if (checkpoint && (checkpoint->expired == 0)) {
|
||||
req_exec_ckpt_checkpointclose.header.size =
|
||||
sizeof (struct req_exec_ckpt_checkpointclose);
|
||||
req_exec_ckpt_checkpointclose.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE;
|
||||
req_exec_ckpt_checkpointclose.header.id =
|
||||
SERVICE_ID_MAKE (CKPT_SERVICE,
|
||||
MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE);
|
||||
|
||||
message_source_set (&req_exec_ckpt_checkpointclose.source, conn_info);
|
||||
|
||||
@ -2885,7 +2958,8 @@ static int message_handler_req_lib_ckpt_checkpointunlink (struct conn_info *conn
|
||||
|
||||
req_exec_ckpt_checkpointunlink.header.size =
|
||||
sizeof (struct req_exec_ckpt_checkpointunlink);
|
||||
req_exec_ckpt_checkpointunlink.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK;
|
||||
req_exec_ckpt_checkpointunlink.header.id =
|
||||
SERVICE_ID_MAKE (CKPT_SERVICE, MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK);
|
||||
|
||||
message_source_set (&req_exec_ckpt_checkpointunlink.source, conn_info);
|
||||
|
||||
@ -2908,7 +2982,9 @@ static int message_handler_req_lib_ckpt_checkpointretentiondurationset (struct c
|
||||
struct iovec iovecs[2];
|
||||
|
||||
log_printf (LOG_LEVEL_DEBUG, "DURATION SET FROM API fd %d\n", conn_info->fd);
|
||||
req_exec_ckpt_checkpointretentiondurationset.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONSET;
|
||||
req_exec_ckpt_checkpointretentiondurationset.header.id =
|
||||
SERVICE_ID_MAKE (CKPT_SERVICE,
|
||||
MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONSET);
|
||||
req_exec_ckpt_checkpointretentiondurationset.header.size = sizeof (struct req_exec_ckpt_checkpointretentiondurationset);
|
||||
|
||||
message_source_set (&req_exec_ckpt_checkpointretentiondurationset.source, conn_info);
|
||||
@ -3027,7 +3103,9 @@ static int message_handler_req_lib_ckpt_sectioncreate (struct conn_info *conn_in
|
||||
/*
|
||||
* checkpoint opened is writeable mode so send message to cluster
|
||||
*/
|
||||
req_exec_ckpt_sectioncreate.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONCREATE;
|
||||
req_exec_ckpt_sectioncreate.header.id =
|
||||
SERVICE_ID_MAKE (CKPT_SERVICE,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONCREATE);
|
||||
req_exec_ckpt_sectioncreate.header.size = sizeof (struct req_exec_ckpt_sectioncreate);
|
||||
|
||||
memcpy (&req_exec_ckpt_sectioncreate.req_lib_ckpt_sectioncreate,
|
||||
@ -3099,7 +3177,9 @@ static int message_handler_req_lib_ckpt_sectiondelete (struct conn_info *conn_in
|
||||
|
||||
log_printf (LOG_LEVEL_DEBUG, "section delete from API fd %d\n", conn_info->fd);
|
||||
|
||||
req_exec_ckpt_sectiondelete.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONDELETE;
|
||||
req_exec_ckpt_sectiondelete.header.id =
|
||||
SERVICE_ID_MAKE (CKPT_SERVICE,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONDELETE);
|
||||
req_exec_ckpt_sectiondelete.header.size = sizeof (struct req_exec_ckpt_sectiondelete);
|
||||
|
||||
memcpy (&req_exec_ckpt_sectiondelete.checkpointName,
|
||||
@ -3138,7 +3218,9 @@ static int message_handler_req_lib_ckpt_sectionexpirationtimeset (struct conn_in
|
||||
struct iovec iovecs[2];
|
||||
|
||||
log_printf (LOG_LEVEL_DEBUG, "section expiration time set fd=%d\n", conn_info->fd);
|
||||
req_exec_ckpt_sectionexpirationtimeset.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONEXPIRATIONTIMESET;
|
||||
req_exec_ckpt_sectionexpirationtimeset.header.id =
|
||||
SERVICE_ID_MAKE (CKPT_SERVICE,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONEXPIRATIONTIMESET);
|
||||
req_exec_ckpt_sectionexpirationtimeset.header.size = sizeof (struct req_exec_ckpt_sectionexpirationtimeset);
|
||||
|
||||
memcpy (&req_exec_ckpt_sectionexpirationtimeset.checkpointName,
|
||||
@ -3195,7 +3277,9 @@ static int message_handler_req_lib_ckpt_sectionwrite (struct conn_info *conn_inf
|
||||
/*
|
||||
* checkpoint opened is writeable mode so send message to cluster
|
||||
*/
|
||||
req_exec_ckpt_sectionwrite.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONWRITE;
|
||||
req_exec_ckpt_sectionwrite.header.id =
|
||||
SERVICE_ID_MAKE (CKPT_SERVICE,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONWRITE);
|
||||
req_exec_ckpt_sectionwrite.header.size = sizeof (struct req_exec_ckpt_sectionwrite);
|
||||
|
||||
memcpy (&req_exec_ckpt_sectionwrite.req_lib_ckpt_sectionwrite,
|
||||
@ -3253,7 +3337,9 @@ static int message_handler_req_lib_ckpt_sectionoverwrite (struct conn_info *conn
|
||||
/*
|
||||
* checkpoint opened is writeable mode so send message to cluster
|
||||
*/
|
||||
req_exec_ckpt_sectionoverwrite.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONOVERWRITE;
|
||||
req_exec_ckpt_sectionoverwrite.header.id =
|
||||
SERVICE_ID_MAKE (CKPT_SERVICE,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONOVERWRITE);
|
||||
req_exec_ckpt_sectionoverwrite.header.size = sizeof (struct req_exec_ckpt_sectionoverwrite);
|
||||
|
||||
memcpy (&req_exec_ckpt_sectionoverwrite.req_lib_ckpt_sectionoverwrite,
|
||||
@ -3317,7 +3403,9 @@ static int message_handler_req_lib_ckpt_sectionread (struct conn_info *conn_info
|
||||
/*
|
||||
* checkpoint opened is writeable mode so send message to cluster
|
||||
*/
|
||||
req_exec_ckpt_sectionread.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONREAD;
|
||||
req_exec_ckpt_sectionread.header.id =
|
||||
SERVICE_ID_MAKE (CKPT_SERVICE,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONREAD);
|
||||
req_exec_ckpt_sectionread.header.size = sizeof (struct req_exec_ckpt_sectionread);
|
||||
|
||||
memcpy (&req_exec_ckpt_sectionread.req_lib_ckpt_sectionread,
|
||||
|
54
exec/clm.c
54
exec/clm.c
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* vi: set autoindent tabstop=4 shiftwidth=4 :
|
||||
*
|
||||
* Copyright (c) 2002-2005 MontaVista Software, Inc.
|
||||
* Copyright (c) 2002-2006 MontaVista Software, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -57,6 +57,7 @@
|
||||
#include "../include/ipc_clm.h"
|
||||
#include "../include/list.h"
|
||||
#include "../include/queue.h"
|
||||
#include "../lcr/lcr_comp.h"
|
||||
#include "aispoll.h"
|
||||
#include "totempg.h"
|
||||
#include "main.h"
|
||||
@ -66,6 +67,11 @@
|
||||
#define LOG_SERVICE LOG_SERVICE_CLM
|
||||
#include "print.h"
|
||||
|
||||
|
||||
enum clm_message_req_types {
|
||||
MESSAGE_REQ_EXEC_CLM_NODEJOIN = 0
|
||||
};
|
||||
|
||||
SaClmClusterChangesT thisClusterNodeLastChange = SA_CLM_NODE_JOINED;
|
||||
SaClmClusterNodeT thisClusterNode;
|
||||
|
||||
@ -175,6 +181,8 @@ static int (*clm_aisexec_handler_fns[]) (void *, struct totem_ip_address *source
|
||||
};
|
||||
|
||||
struct service_handler clm_service_handler = {
|
||||
.name = "openais cluster membership service B.01.01",
|
||||
.id = CLM_SERVICE,
|
||||
.libais_handlers = clm_libais_handlers,
|
||||
.libais_handlers_count = sizeof (clm_libais_handlers) / sizeof (struct libais_handler),
|
||||
.aisexec_handler_fns = clm_aisexec_handler_fns,
|
||||
@ -190,6 +198,46 @@ struct service_handler clm_service_handler = {
|
||||
.sync_abort = clm_sync_abort,
|
||||
};
|
||||
|
||||
#ifdef BUILD_DYNAMIC
|
||||
struct service_handler *clm_get_handler_ver0 (void);
|
||||
|
||||
struct aisexec_iface_ver0 clm_service_handler_iface = {
|
||||
.test = NULL,
|
||||
.get_handler_ver0 = clm_get_handler_ver0
|
||||
};
|
||||
|
||||
struct lcr_iface openais_clm_ver0[1] = {
|
||||
{
|
||||
.name = "openais_clm",
|
||||
.version = 0,
|
||||
.versions_replace = 0,
|
||||
.versions_replace_count = 0,
|
||||
.dependencies = 0,
|
||||
.dependency_count = 0,
|
||||
.constructor = NULL,
|
||||
.destructor = NULL,
|
||||
.interfaces = (void **)&clm_service_handler_iface,
|
||||
}
|
||||
};
|
||||
|
||||
struct lcr_comp clm_comp_ver0 = {
|
||||
.iface_count = 1,
|
||||
.ifaces = openais_clm_ver0
|
||||
};
|
||||
|
||||
|
||||
extern int lcr_comp_get (struct lcr_comp **component)
|
||||
{
|
||||
*component = &clm_comp_ver0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
struct service_handler *clm_get_handler_ver0 (void)
|
||||
{
|
||||
return (&clm_service_handler);
|
||||
}
|
||||
#endif /* BUILD_DYNAMIC */
|
||||
|
||||
struct req_exec_clm_nodejoin {
|
||||
struct req_header header;
|
||||
SaClmClusterNodeT clusterNode;
|
||||
@ -234,6 +282,7 @@ static int clm_exec_init_fn (struct openais_config *openais_config)
|
||||
memcpy (&clusterNodes[0], &thisClusterNode, sizeof (SaClmClusterNodeT));
|
||||
clusterNodeEntries = 1;
|
||||
|
||||
main_clm_get_by_nodeid = clm_get_by_nodeid;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -375,7 +424,8 @@ static int clm_nodejoin_send (void)
|
||||
int result;
|
||||
|
||||
req_exec_clm_nodejoin.header.size = sizeof (struct req_exec_clm_nodejoin);
|
||||
req_exec_clm_nodejoin.header.id = MESSAGE_REQ_EXEC_CLM_NODEJOIN;
|
||||
req_exec_clm_nodejoin.header.id =
|
||||
SERVICE_ID_MAKE (CLM_SERVICE, MESSAGE_REQ_EXEC_CLM_NODEJOIN);
|
||||
// TODO dont use memcpy, use iovecs !!
|
||||
|
||||
thisClusterNode.initialViewNumber = view_initial;
|
||||
|
60
exec/evs.c
60
exec/evs.c
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* vi: set autoindent tabstop=4 shiftwidth=4 :
|
||||
*
|
||||
* Copyright (c) 2004 MontaVista Software, Inc.
|
||||
* Copyright (c) 2004-2006 MontaVista Software, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -52,12 +52,13 @@
|
||||
|
||||
#include "../include/saAis.h"
|
||||
#include "../include/ipc_gen.h"
|
||||
#include "totemip.h"
|
||||
#include "../include/ipc_evs.h"
|
||||
#include "../include/list.h"
|
||||
#include "../include/queue.h"
|
||||
#include "../lcr/lcr_comp.h"
|
||||
#include "aispoll.h"
|
||||
#include "totempg.h"
|
||||
#include "totemip.h"
|
||||
#include "main.h"
|
||||
#include "mempool.h"
|
||||
#include "handlers.h"
|
||||
@ -65,7 +66,9 @@
|
||||
#define LOG_SERVICE LOG_SERVICE_EVS
|
||||
#include "print.h"
|
||||
|
||||
static DECLARE_LIST_INIT (confchg_notify);
|
||||
enum evs_exec_message_req_types {
|
||||
MESSAGE_REQ_EXEC_EVS_MCAST = 0
|
||||
};
|
||||
|
||||
/*
|
||||
* Service Interfaces required by service_message_handler struct
|
||||
@ -130,6 +133,8 @@ static int (*evs_aisexec_handler_fns[]) (void *, struct totem_ip_address *source
|
||||
};
|
||||
|
||||
struct service_handler evs_service_handler = {
|
||||
.name = "openais extended virtual synchrony service",
|
||||
.id = EVS_SERVICE,
|
||||
.libais_handlers = evs_libais_handlers,
|
||||
.libais_handlers_count = sizeof (evs_libais_handlers) / sizeof (struct libais_handler),
|
||||
.aisexec_handler_fns = evs_aisexec_handler_fns,
|
||||
@ -141,6 +146,49 @@ struct service_handler evs_service_handler = {
|
||||
.exec_dump_fn = 0
|
||||
};
|
||||
|
||||
static DECLARE_LIST_INIT (confchg_notify);
|
||||
|
||||
#ifdef BUILD_DYNAMIC
|
||||
|
||||
struct service_handler *evs_get_handler_ver0 (void);
|
||||
|
||||
struct aisexec_iface_ver0 evs_service_handler_iface = {
|
||||
.test = NULL,
|
||||
.get_handler_ver0 = evs_get_handler_ver0
|
||||
};
|
||||
|
||||
struct lcr_iface openais_evs_ver0[1] = {
|
||||
{
|
||||
.name = "openais_evs",
|
||||
.version = 0,
|
||||
.versions_replace = 0,
|
||||
.versions_replace_count = 0,
|
||||
.dependencies = 0,
|
||||
.dependency_count = 0,
|
||||
.constructor = NULL,
|
||||
.destructor = NULL,
|
||||
.interfaces = (void **)&evs_service_handler_iface,
|
||||
}
|
||||
};
|
||||
|
||||
struct lcr_comp evs_comp_ver0 = {
|
||||
.iface_count = 1,
|
||||
.ifaces = openais_evs_ver0
|
||||
};
|
||||
|
||||
extern int lcr_comp_get (struct lcr_comp **component)
|
||||
{
|
||||
*component = &evs_comp_ver0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
struct service_handler *evs_get_handler_ver0 (void)
|
||||
{
|
||||
return (&evs_service_handler);
|
||||
}
|
||||
|
||||
#endif /* BUILD_DYNAMIC */
|
||||
|
||||
static int evs_executive_initialize (struct openais_config *openais_config)
|
||||
{
|
||||
return (0);
|
||||
@ -329,7 +377,8 @@ static int message_handler_req_evs_mcast_joined (struct conn_info *conn_info, vo
|
||||
sizeof (struct evs_group) +
|
||||
req_lib_evs_mcast_joined->msg_len;
|
||||
|
||||
req_exec_evs_mcast.header.id = MESSAGE_REQ_EXEC_EVS_MCAST;
|
||||
req_exec_evs_mcast.header.id =
|
||||
SERVICE_ID_MAKE (EVS_SERVICE, MESSAGE_REQ_EXEC_EVS_MCAST);
|
||||
req_exec_evs_mcast.msg_len = req_lib_evs_mcast_joined->msg_len;
|
||||
req_exec_evs_mcast.group_entries = conn_info->conn_info_partner->ais_ci.u.libevs_ci.group_entries;
|
||||
|
||||
@ -373,7 +422,8 @@ static int message_handler_req_evs_mcast_groups (struct conn_info *conn_info, vo
|
||||
sizeof (struct evs_group) * req_lib_evs_mcast_groups->group_entries +
|
||||
req_lib_evs_mcast_groups->msg_len;
|
||||
|
||||
req_exec_evs_mcast.header.id = MESSAGE_REQ_EXEC_EVS_MCAST;
|
||||
req_exec_evs_mcast.header.id =
|
||||
SERVICE_ID_MAKE (EVS_SERVICE, MESSAGE_REQ_EXEC_EVS_MCAST);
|
||||
req_exec_evs_mcast.msg_len = req_lib_evs_mcast_groups->msg_len;
|
||||
req_exec_evs_mcast.group_entries = req_lib_evs_mcast_groups->group_entries;
|
||||
|
||||
|
168
exec/evt.c
168
exec/evt.c
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2004 Mark Haverkamp
|
||||
* Copyright (c) 2004 Open Source Development Lab
|
||||
* Copyright (c) 2004-2006 Mark Haverkamp
|
||||
* Copyright (c) 2004-2006 Open Source Development Lab
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -48,16 +48,17 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include "../include/hdb.h"
|
||||
#include "../include/ipc_evt.h"
|
||||
#include "../include/list.h"
|
||||
#include "../include/queue.h"
|
||||
#include "../lcr/lcr_comp.h"
|
||||
#include "util.h"
|
||||
#include "aispoll.h"
|
||||
#include "mempool.h"
|
||||
#include "main.h"
|
||||
#include "totemip.h"
|
||||
#include "totempg.h"
|
||||
#include "hdb.h"
|
||||
#include "clm.h"
|
||||
#include "evt.h"
|
||||
#include "swab.h"
|
||||
@ -65,6 +66,12 @@
|
||||
#define LOG_SERVICE LOG_SERVICE_EVT
|
||||
#include "print.h"
|
||||
|
||||
enum evt_message_req_types {
|
||||
MESSAGE_REQ_EXEC_EVT_EVENTDATA = 0,
|
||||
MESSAGE_REQ_EXEC_EVT_CHANCMD = 1,
|
||||
MESSAGE_REQ_EXEC_EVT_RECOVERY_EVENTDATA = 2
|
||||
};
|
||||
|
||||
static int lib_evt_open_channel(struct conn_info *conn_info, void *message);
|
||||
static int lib_evt_open_channel_async(struct conn_info *conn_info,
|
||||
void *message);
|
||||
@ -173,6 +180,9 @@ static int (*evt_exec_handler_fns[]) (void *m, struct totem_ip_address *s,
|
||||
};
|
||||
|
||||
struct service_handler evt_service_handler = {
|
||||
.name =
|
||||
(unsigned char*)"openais event service B.01.01",
|
||||
.id = EVT_SERVICE,
|
||||
.libais_handlers = evt_libais_handlers,
|
||||
.libais_handlers_count = sizeof(evt_libais_handlers) /
|
||||
sizeof(struct libais_handler),
|
||||
@ -190,6 +200,45 @@ struct service_handler evt_service_handler = {
|
||||
.sync_abort = evt_sync_abort
|
||||
};
|
||||
|
||||
#ifdef BUILD_DYNAMIC
|
||||
struct service_handler *evt_get_handler_ver0 (void);
|
||||
|
||||
struct aisexec_iface_ver0 evt_service_handler_iface = {
|
||||
.test = NULL,
|
||||
.get_handler_ver0 = evt_get_handler_ver0
|
||||
};
|
||||
|
||||
struct lcr_iface openais_evt_ver0[1] = {
|
||||
{
|
||||
.name = "openais_evt",
|
||||
.version = 0,
|
||||
.versions_replace = 0,
|
||||
.versions_replace_count = 0,
|
||||
.dependencies = 0,
|
||||
.dependency_count = 0,
|
||||
.constructor = NULL,
|
||||
.destructor = NULL,
|
||||
.interfaces = (void **)&evt_service_handler_iface,
|
||||
}
|
||||
};
|
||||
|
||||
struct lcr_comp evt_comp_ver0 = {
|
||||
.iface_count = 1,
|
||||
.ifaces = openais_evt_ver0
|
||||
};
|
||||
|
||||
extern int lcr_comp_get (struct lcr_comp **component)
|
||||
{
|
||||
*component = &evt_comp_ver0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
struct service_handler *evt_get_handler_ver0 (void)
|
||||
{
|
||||
return (&evt_service_handler);
|
||||
}
|
||||
|
||||
#endif /* BUILD_DYNAMIC */
|
||||
|
||||
/*
|
||||
* list of all retained events
|
||||
@ -1107,7 +1156,8 @@ static SaErrorT evt_open_channel(SaNameT *cn, SaUint8T flgs)
|
||||
* to create the channel.
|
||||
*/
|
||||
memset(&cpkt, 0, sizeof(cpkt));
|
||||
cpkt.chc_head.id = MESSAGE_REQ_EXEC_EVT_CHANCMD;
|
||||
cpkt.chc_head.id =
|
||||
SERVICE_ID_MAKE (EVT_SERVICE, MESSAGE_REQ_EXEC_EVT_CHANCMD);
|
||||
cpkt.chc_head.size = sizeof(cpkt);
|
||||
cpkt.chc_op = EVT_OPEN_CHAN_OP;
|
||||
cpkt.u.chc_chan.ocr_name = *cn;
|
||||
@ -1144,7 +1194,8 @@ static SaErrorT evt_close_channel(SaNameT *cn, uint64_t unlink_id)
|
||||
* to close the channel.
|
||||
*/
|
||||
memset(&cpkt, 0, sizeof(cpkt));
|
||||
cpkt.chc_head.id = MESSAGE_REQ_EXEC_EVT_CHANCMD;
|
||||
cpkt.chc_head.id =
|
||||
SERVICE_ID_MAKE (EVT_SERVICE, MESSAGE_REQ_EXEC_EVT_CHANCMD);
|
||||
cpkt.chc_head.size = sizeof(cpkt);
|
||||
cpkt.chc_op = EVT_CLOSE_CHAN_OP;
|
||||
cpkt.u.chcu.chcu_name = *cn;
|
||||
@ -1297,7 +1348,7 @@ static int check_last_event(struct lib_event_data *evtpkt,
|
||||
log_printf(LOG_LEVEL_DEBUG,
|
||||
"Node ID 0x%x not found for event %llx\n",
|
||||
evtpkt->led_publisher_node_id, evtpkt->led_event_id);
|
||||
cn = clm_get_by_nodeid(addr->nodeid);
|
||||
cn = main_clm_get_by_nodeid(addr->nodeid);
|
||||
if (!cn) {
|
||||
log_printf(LOG_LEVEL_DEBUG,
|
||||
"Cluster Node 0x%x not found for event %llx\n",
|
||||
@ -2251,7 +2302,7 @@ static int lib_evt_close_channel(struct conn_info *conn_info, void *message)
|
||||
struct res_evt_channel_close res;
|
||||
struct event_svr_channel_open *eco;
|
||||
struct libevt_ci *esip = &conn_info->ais_ci.u.libevt_ci;
|
||||
SaErrorT error;
|
||||
unsigned int ret;
|
||||
void *ptr;
|
||||
|
||||
req = message;
|
||||
@ -2263,21 +2314,21 @@ static int lib_evt_close_channel(struct conn_info *conn_info, void *message)
|
||||
/*
|
||||
* look up the channel handle
|
||||
*/
|
||||
error = saHandleInstanceGet(&esip->esi_hdb,
|
||||
ret = hdb_handle_get(&esip->esi_hdb,
|
||||
req->icc_channel_handle, &ptr);
|
||||
if (error != SA_AIS_OK) {
|
||||
if (ret != 0) {
|
||||
goto chan_close_done;
|
||||
}
|
||||
eco = ptr;
|
||||
|
||||
common_chan_close(eco, esip);
|
||||
saHandleDestroy(&esip->esi_hdb, req->icc_channel_handle);
|
||||
saHandleInstancePut(&esip->esi_hdb, req->icc_channel_handle);
|
||||
hdb_handle_destroy(&esip->esi_hdb, req->icc_channel_handle);
|
||||
hdb_handle_put(&esip->esi_hdb, req->icc_channel_handle);
|
||||
|
||||
chan_close_done:
|
||||
res.icc_head.size = sizeof(res);
|
||||
res.icc_head.id = MESSAGE_RES_EVT_CLOSE_CHANNEL;
|
||||
res.icc_head.error = error;
|
||||
res.icc_head.error = ((ret == 0) ? SA_AIS_OK : SA_AIS_ERR_BAD_HANDLE);
|
||||
libais_send_response (conn_info, &res, sizeof(res));
|
||||
|
||||
return 0;
|
||||
@ -2331,7 +2382,8 @@ static int lib_evt_unlink_channel(struct conn_info *conn_info, void *message)
|
||||
* of the channel unlink.
|
||||
*/
|
||||
memset(&cpkt, 0, sizeof(cpkt));
|
||||
cpkt.chc_head.id = MESSAGE_REQ_EXEC_EVT_CHANCMD;
|
||||
cpkt.chc_head.id =
|
||||
SERVICE_ID_MAKE (EVT_SERVICE, MESSAGE_REQ_EXEC_EVT_CHANCMD);
|
||||
cpkt.chc_head.size = sizeof(cpkt);
|
||||
cpkt.chc_op = EVT_UNLINK_CHAN_OP;
|
||||
cpkt.u.chcu.chcu_name = req->iuc_channel_name;
|
||||
@ -2388,6 +2440,7 @@ static int lib_evt_event_subscribe(struct conn_info *conn_info, void *message)
|
||||
struct libevt_ci *esip = &conn_info->ais_ci.u.libevt_ci;
|
||||
struct list_head *l;
|
||||
void *ptr;
|
||||
unsigned int ret;
|
||||
int i;
|
||||
|
||||
req = message;
|
||||
@ -2400,9 +2453,10 @@ static int lib_evt_event_subscribe(struct conn_info *conn_info, void *message)
|
||||
/*
|
||||
* look up the channel handle
|
||||
*/
|
||||
error = saHandleInstanceGet(&esip->esi_hdb,
|
||||
ret = hdb_handle_get(&esip->esi_hdb,
|
||||
req->ics_channel_handle, &ptr);
|
||||
if (error != SA_AIS_OK) {
|
||||
if (ret != 0) {
|
||||
error = SA_AIS_ERR_BAD_HANDLE;
|
||||
goto subr_done;
|
||||
}
|
||||
eco = ptr;
|
||||
@ -2475,11 +2529,11 @@ static int lib_evt_event_subscribe(struct conn_info *conn_info, void *message)
|
||||
}
|
||||
}
|
||||
}
|
||||
saHandleInstancePut(&esip->esi_hdb, req->ics_channel_handle);
|
||||
hdb_handle_put(&esip->esi_hdb, req->ics_channel_handle);
|
||||
return 0;
|
||||
|
||||
subr_put:
|
||||
saHandleInstancePut(&esip->esi_hdb, req->ics_channel_handle);
|
||||
hdb_handle_put(&esip->esi_hdb, req->ics_channel_handle);
|
||||
subr_done:
|
||||
res.ics_head.size = sizeof(res);
|
||||
res.ics_head.id = MESSAGE_RES_EVT_SUBSCRIBE;
|
||||
@ -2502,6 +2556,7 @@ static int lib_evt_event_unsubscribe(struct conn_info *conn_info,
|
||||
struct event_svr_channel_subscr *ecs;
|
||||
struct libevt_ci *esip = &conn_info->ais_ci.u.libevt_ci;
|
||||
SaErrorT error = SA_AIS_OK;
|
||||
unsigned int ret;
|
||||
void *ptr;
|
||||
|
||||
req = message;
|
||||
@ -2515,9 +2570,10 @@ static int lib_evt_event_unsubscribe(struct conn_info *conn_info,
|
||||
* look up the channel handle, get the open channel
|
||||
* data.
|
||||
*/
|
||||
error = saHandleInstanceGet(&esip->esi_hdb,
|
||||
ret = hdb_handle_get(&esip->esi_hdb,
|
||||
req->icu_channel_handle, &ptr);
|
||||
if (error != SA_AIS_OK) {
|
||||
if (ret != 0) {
|
||||
error = SA_AIS_ERR_BAD_HANDLE;
|
||||
goto unsubr_done;
|
||||
}
|
||||
eco = ptr;
|
||||
@ -2545,7 +2601,7 @@ static int lib_evt_event_unsubscribe(struct conn_info *conn_info,
|
||||
free(ecs);
|
||||
|
||||
unsubr_put:
|
||||
saHandleInstancePut(&esip->esi_hdb, req->icu_channel_handle);
|
||||
hdb_handle_put(&esip->esi_hdb, req->icu_channel_handle);
|
||||
unsubr_done:
|
||||
res.icu_head.size = sizeof(res);
|
||||
res.icu_head.id = MESSAGE_RES_EVT_UNSUBSCRIBE;
|
||||
@ -2571,6 +2627,7 @@ static int lib_evt_event_publish(struct conn_info *conn_info, void *message)
|
||||
struct iovec pub_iovec;
|
||||
void *ptr;
|
||||
int result;
|
||||
unsigned int ret;
|
||||
|
||||
|
||||
req = message;
|
||||
@ -2582,9 +2639,10 @@ static int lib_evt_event_publish(struct conn_info *conn_info, void *message)
|
||||
/*
|
||||
* look up and validate open channel info
|
||||
*/
|
||||
error = saHandleInstanceGet(&esip->esi_hdb,
|
||||
ret = hdb_handle_get(&esip->esi_hdb,
|
||||
req->led_svr_channel_handle, &ptr);
|
||||
if (error != SA_AIS_OK) {
|
||||
if (ret != 0) {
|
||||
error = SA_AIS_ERR_BAD_HANDLE;
|
||||
goto pub_done;
|
||||
}
|
||||
eco = ptr;
|
||||
@ -2596,7 +2654,7 @@ static int lib_evt_event_publish(struct conn_info *conn_info, void *message)
|
||||
* processes.
|
||||
*/
|
||||
get_event_id(&event_id, &msg_id);
|
||||
req->led_head.id = MESSAGE_REQ_EXEC_EVT_EVENTDATA;
|
||||
req->led_head.id = SERVICE_ID_MAKE (EVT_SERVICE, MESSAGE_REQ_EXEC_EVT_EVENTDATA);
|
||||
req->led_chan_name = eci->esc_channel_name;
|
||||
req->led_event_id = event_id;
|
||||
req->led_msg_id = msg_id;
|
||||
@ -2614,7 +2672,7 @@ static int lib_evt_event_publish(struct conn_info *conn_info, void *message)
|
||||
error = SA_AIS_ERR_LIBRARY;
|
||||
}
|
||||
|
||||
saHandleInstancePut(&esip->esi_hdb, req->led_svr_channel_handle);
|
||||
hdb_handle_put(&esip->esi_hdb, req->led_svr_channel_handle);
|
||||
pub_done:
|
||||
res.iep_head.size = sizeof(res);
|
||||
res.iep_head.id = MESSAGE_RES_EVT_PUBLISH;
|
||||
@ -2664,7 +2722,8 @@ static int lib_evt_event_clear_retentiontime(struct conn_info *conn_info,
|
||||
* Send the clear request
|
||||
*/
|
||||
memset(&cpkt, 0, sizeof(cpkt));
|
||||
cpkt.chc_head.id = MESSAGE_REQ_EXEC_EVT_CHANCMD;
|
||||
cpkt.chc_head.id =
|
||||
SERVICE_ID_MAKE (EVT_SERVICE, MESSAGE_REQ_EXEC_EVT_CHANCMD);
|
||||
cpkt.chc_head.size = sizeof(cpkt);
|
||||
cpkt.chc_op = EVT_CLEAR_RET_OP;
|
||||
cpkt.u.chc_event_id = req->iec_event_id;
|
||||
@ -2909,7 +2968,7 @@ static int evt_finalize(struct conn_info *conn_info)
|
||||
nxt = l->next;
|
||||
eco = list_entry(l, struct event_svr_channel_open, eco_instance_entry);
|
||||
common_chan_close(eco, esip);
|
||||
saHandleDestroy(&esip->esi_hdb, eco->eco_my_handle);
|
||||
hdb_handle_destroy(&esip->esi_hdb, eco->eco_my_handle);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -3064,7 +3123,7 @@ static int evt_remote_evt(void *msg, struct totem_ip_address *source_addr,
|
||||
* See where the message came from so that we can set the
|
||||
* publishing node id in the message before delivery.
|
||||
*/
|
||||
cn = clm_get_by_nodeid (source_addr->nodeid);
|
||||
cn = main_clm_get_by_nodeid (source_addr->nodeid);
|
||||
if (!cn) {
|
||||
/*
|
||||
* Not sure how this can happen...
|
||||
@ -3292,16 +3351,18 @@ static void evt_chan_open_finish(struct open_chan_pending *ocp,
|
||||
{
|
||||
uint32_t handle;
|
||||
struct event_svr_channel_open *eco;
|
||||
SaErrorT error;
|
||||
SaErrorT error = SA_AIS_OK;
|
||||
struct libevt_ci *esip = &ocp->ocp_conn_info->ais_ci.u.libevt_ci;
|
||||
int ret = 0;
|
||||
unsigned int ret = 0;
|
||||
unsigned int timer_del_status;
|
||||
void *ptr;
|
||||
|
||||
log_printf(CHAN_OPEN_DEBUG, "Open channel finish %s\n",
|
||||
getSaNameT(&ocp->ocp_chan_name));
|
||||
if (ocp->ocp_timer_handle) {
|
||||
ret = poll_timer_delete(aisexec_poll_handle, ocp->ocp_timer_handle);
|
||||
if (ret != 0 ) {
|
||||
timer_del_status = poll_timer_delete(aisexec_poll_handle,
|
||||
ocp->ocp_timer_handle);
|
||||
if (timer_del_status != 0) {
|
||||
log_printf(LOG_LEVEL_WARNING,
|
||||
"Error clearing timeout for open channel of %s\n",
|
||||
getSaNameT(&ocp->ocp_chan_name));
|
||||
@ -3330,12 +3391,12 @@ static void evt_chan_open_finish(struct open_chan_pending *ocp,
|
||||
* Create a handle to give back to the caller to associate
|
||||
* with this channel open instance.
|
||||
*/
|
||||
error = saHandleCreate(&esip->esi_hdb, sizeof(*eco), &handle);
|
||||
if (error != SA_AIS_OK) {
|
||||
ret = hdb_handle_create(&esip->esi_hdb, sizeof(*eco), &handle);
|
||||
if (ret != 0) {
|
||||
goto open_return;
|
||||
}
|
||||
error = saHandleInstanceGet(&esip->esi_hdb, handle, &ptr);
|
||||
if (error != SA_AIS_OK) {
|
||||
ret = hdb_handle_get(&esip->esi_hdb, handle, &ptr);
|
||||
if (ret != 0) {
|
||||
goto open_return;
|
||||
}
|
||||
eco = ptr;
|
||||
@ -3358,7 +3419,7 @@ static void evt_chan_open_finish(struct open_chan_pending *ocp,
|
||||
* respond back with a handle to access this channel
|
||||
* open instance for later subscriptions, etc.
|
||||
*/
|
||||
saHandleInstancePut(&esip->esi_hdb, handle);
|
||||
hdb_handle_put(&esip->esi_hdb, handle);
|
||||
|
||||
open_return:
|
||||
log_printf(CHAN_OPEN_DEBUG, "Open channel finish %s send response %d\n",
|
||||
@ -3368,7 +3429,7 @@ open_return:
|
||||
struct res_evt_open_chan_async resa;
|
||||
resa.ica_head.size = sizeof(resa);
|
||||
resa.ica_head.id = MESSAGE_RES_EVT_CHAN_OPEN_CALLBACK;
|
||||
resa.ica_head.error = error;
|
||||
resa.ica_head.error = (ret == 0 ? SA_AIS_OK: SA_AIS_ERR_BAD_HANDLE);
|
||||
resa.ica_channel_handle = handle;
|
||||
resa.ica_c_handle = ocp->ocp_c_handle;
|
||||
resa.ica_invocation = ocp->ocp_invocation;
|
||||
@ -3378,12 +3439,12 @@ open_return:
|
||||
struct res_evt_channel_open res;
|
||||
res.ico_head.size = sizeof(res);
|
||||
res.ico_head.id = MESSAGE_RES_EVT_OPEN_CHANNEL;
|
||||
res.ico_head.error = error;
|
||||
res.ico_head.error = (ret == 0 ? SA_AIS_OK : SA_AIS_ERR_BAD_HANDLE);
|
||||
res.ico_channel_handle = handle;
|
||||
libais_send_response (ocp->ocp_conn_info, &res, sizeof(res));
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
if (timer_del_status == 0) {
|
||||
list_del(&ocp->ocp_entry);
|
||||
free(ocp);
|
||||
}
|
||||
@ -3516,12 +3577,12 @@ static int evt_remote_chan_op(void *msg, struct totem_ip_address *source_addr,
|
||||
}
|
||||
|
||||
log_printf(REMOTE_OP_DEBUG, "Remote channel operation request\n");
|
||||
my_node = clm_get_by_nodeid(local_node);
|
||||
my_node = main_clm_get_by_nodeid(local_node);
|
||||
log_printf(REMOTE_OP_DEBUG, "my node ID: 0x%x\n", my_node->nodeId);
|
||||
|
||||
mn = evt_find_node(source_addr);
|
||||
if (mn == NULL) {
|
||||
cn = clm_get_by_nodeid(source_addr->nodeid);
|
||||
cn = main_clm_get_by_nodeid(source_addr->nodeid);
|
||||
if (cn == NULL) {
|
||||
log_printf(LOG_LEVEL_WARNING,
|
||||
"Evt remote channel op: Node data for addr %s is NULL\n",
|
||||
@ -3866,7 +3927,7 @@ static void evt_sync_init(void)
|
||||
* Set the base event id
|
||||
*/
|
||||
if (!my_node_id) {
|
||||
cn = clm_get_by_nodeid(my_node);
|
||||
cn = main_clm_get_by_nodeid(my_node);
|
||||
log_printf(RECOVERY_DEBUG, "My node ID 0x%x\n", cn->nodeId);
|
||||
my_node_id = cn->nodeId;
|
||||
set_event_id(my_node_id);
|
||||
@ -3976,14 +4037,16 @@ static int evt_sync_process(void)
|
||||
md->mn_last_msg_id, totemip_print(add_list));
|
||||
md->mn_started = 1;
|
||||
memset(&cpkt, 0, sizeof(cpkt));
|
||||
cpkt.chc_head.id = MESSAGE_REQ_EXEC_EVT_CHANCMD;
|
||||
cpkt.chc_head.id =
|
||||
SERVICE_ID_MAKE (EVT_SERVICE, MESSAGE_REQ_EXEC_EVT_CHANCMD);
|
||||
cpkt.chc_head.size = sizeof(cpkt);
|
||||
cpkt.chc_op = EVT_SET_ID_OP;
|
||||
cpkt.u.chc_set_id.chc_nodeid = add_list->nodeid;
|
||||
cpkt.u.chc_set_id.chc_last_id = md->mn_last_msg_id;
|
||||
chn_iovec.iov_base = &cpkt;
|
||||
chn_iovec.iov_len = cpkt.chc_head.size;
|
||||
res = totempg_groups_mcast_joined (openais_group_handle, &chn_iovec, 1,TOTEMPG_AGREED);
|
||||
res = totempg_groups_mcast_joined (openais_group_handle,
|
||||
&chn_iovec, 1, TOTEMPG_AGREED);
|
||||
if (res != 0) {
|
||||
log_printf(RECOVERY_DEBUG,
|
||||
"Unable to send event id to %s\n",
|
||||
@ -3998,7 +4061,7 @@ static int evt_sync_process(void)
|
||||
/*
|
||||
* Not seen before, add it to our list of nodes.
|
||||
*/
|
||||
cn = clm_get_by_nodeid(add_list->nodeid);
|
||||
cn = main_clm_get_by_nodeid(add_list->nodeid);
|
||||
if (!cn) {
|
||||
/*
|
||||
* Error: shouldn't happen
|
||||
@ -4041,14 +4104,16 @@ static int evt_sync_process(void)
|
||||
log_printf(RECOVERY_DEBUG, "Sending next open count\n");
|
||||
eci = list_entry(next_chan, struct event_svr_channel_instance,
|
||||
esc_entry);
|
||||
cpkt.chc_head.id = MESSAGE_REQ_EXEC_EVT_CHANCMD;
|
||||
cpkt.chc_head.id =
|
||||
SERVICE_ID_MAKE (EVT_SERVICE, MESSAGE_REQ_EXEC_EVT_CHANCMD);
|
||||
cpkt.chc_head.size = sizeof(cpkt);
|
||||
cpkt.chc_op = EVT_OPEN_COUNT;
|
||||
cpkt.u.chc_set_opens.chc_chan_name = eci->esc_channel_name;
|
||||
cpkt.u.chc_set_opens.chc_open_count = eci->esc_local_opens;
|
||||
chn_iovec.iov_base = &cpkt;
|
||||
chn_iovec.iov_len = cpkt.chc_head.size;
|
||||
res = totempg_groups_mcast_joined (openais_group_handle, &chn_iovec, 1,TOTEMPG_AGREED);
|
||||
res = totempg_groups_mcast_joined (openais_group_handle,
|
||||
&chn_iovec, 1, TOTEMPG_AGREED);
|
||||
|
||||
if (res != 0) {
|
||||
/*
|
||||
@ -4058,7 +4123,8 @@ static int evt_sync_process(void)
|
||||
}
|
||||
}
|
||||
memset(&cpkt, 0, sizeof(cpkt));
|
||||
cpkt.chc_head.id = MESSAGE_REQ_EXEC_EVT_CHANCMD;
|
||||
cpkt.chc_head.id =
|
||||
SERVICE_ID_MAKE (EVT_SERVICE, MESSAGE_REQ_EXEC_EVT_CHANCMD);
|
||||
cpkt.chc_head.size = sizeof(cpkt);
|
||||
cpkt.chc_op = EVT_OPEN_COUNT_DONE;
|
||||
chn_iovec.iov_base = &cpkt;
|
||||
@ -4107,7 +4173,8 @@ static int evt_sync_process(void)
|
||||
next_retained = next_retained->next) {
|
||||
log_printf(LOG_LEVEL_DEBUG, "Sending next retained event\n");
|
||||
evt = list_entry(next_retained, struct event_data, ed_retained);
|
||||
evt->ed_event.led_head.id = MESSAGE_REQ_EXEC_EVT_RECOVERY_EVENTDATA;
|
||||
evt->ed_event.led_head.id =
|
||||
SERVICE_ID_MAKE (EVT_SERVICE, MESSAGE_REQ_EXEC_EVT_RECOVERY_EVENTDATA);
|
||||
chn_iovec.iov_base = &evt->ed_event;
|
||||
chn_iovec.iov_len = evt->ed_event.led_head.size;
|
||||
res = totempg_groups_mcast_joined (openais_group_handle, &chn_iovec, 1, TOTEMPG_AGREED);
|
||||
@ -4132,7 +4199,8 @@ static int evt_sync_process(void)
|
||||
|
||||
log_printf(RECOVERY_DEBUG, "DONE Sending retained events\n");
|
||||
memset(&cpkt, 0, sizeof(cpkt));
|
||||
cpkt.chc_head.id = MESSAGE_REQ_EXEC_EVT_CHANCMD;
|
||||
cpkt.chc_head.id =
|
||||
SERVICE_ID_MAKE (EVT_SERVICE, MESSAGE_REQ_EXEC_EVT_CHANCMD);
|
||||
cpkt.chc_head.size = sizeof(cpkt);
|
||||
cpkt.chc_op = EVT_CONF_DONE;
|
||||
chn_iovec.iov_base = &cpkt;
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
#ifndef EVT_H
|
||||
#define EVT_H
|
||||
#include "hdb.h"
|
||||
#include "../include/hdb.h"
|
||||
#include "../include/list.h"
|
||||
#include "../include/saEvt.h"
|
||||
|
||||
@ -64,7 +64,7 @@ struct libevt_ci {
|
||||
struct list_head esi_events[SA_EVT_LOWEST_PRIORITY+1];
|
||||
int esi_nevents;
|
||||
int esi_queue_blocked;
|
||||
struct saHandleDatabase esi_hdb;
|
||||
struct hdb_handle_database esi_hdb;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2004 MontaVista Software, Inc.
|
||||
* Copyright (c) 2002-2006 MontaVista Software, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -39,6 +39,8 @@
|
||||
#include "totempg.h"
|
||||
#include "totemsrp.h"
|
||||
|
||||
#define SERVICE_ID_MAKE(a,b) ( ((a)<<16) | (b) )
|
||||
|
||||
enum flow_control {
|
||||
FLOW_CONTROL_REQUIRED = 1,
|
||||
FLOW_CONTROL_NOT_REQUIRED = 2
|
||||
@ -52,6 +54,8 @@ struct libais_handler {
|
||||
};
|
||||
|
||||
struct service_handler {
|
||||
unsigned char *name;
|
||||
unsigned short id;
|
||||
struct libais_handler *libais_handlers;
|
||||
int libais_handlers_count;
|
||||
int (**aisexec_handler_fns) (void *msg, struct totem_ip_address *source_addr, int endian_conversion_needed);
|
||||
@ -74,4 +78,9 @@ struct service_handler {
|
||||
void (*sync_abort) (void);
|
||||
};
|
||||
|
||||
struct aisexec_iface_ver0 {
|
||||
void (*test) (void);
|
||||
struct service_handler *(*get_handler_ver0) (void);
|
||||
};
|
||||
|
||||
#endif /* HANDLERS_H_DEFINED */
|
||||
|
153
exec/hdb.c
153
exec/hdb.c
@ -1,153 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2004 MontaVista Software, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* 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
|
||||
* 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
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "hdb.h"
|
||||
|
||||
enum SA_HANDLE_STATE {
|
||||
SA_HANDLE_STATE_EMPTY,
|
||||
SA_HANDLE_STATE_PENDINGREMOVAL,
|
||||
SA_HANDLE_STATE_ACTIVE
|
||||
};
|
||||
|
||||
struct saHandle {
|
||||
int state;
|
||||
void *instance;
|
||||
int refCount;
|
||||
};
|
||||
|
||||
SaErrorT
|
||||
saHandleCreate (
|
||||
struct saHandleDatabase *handleDatabase,
|
||||
int instanceSize,
|
||||
unsigned int *handleOut)
|
||||
{
|
||||
int handle;
|
||||
void *newHandles;
|
||||
int found = 0;
|
||||
void *instance;
|
||||
|
||||
for (handle = 0; handle < handleDatabase->handleCount; handle++) {
|
||||
if (handleDatabase->handles[handle].state == SA_HANDLE_STATE_EMPTY) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == 0) {
|
||||
handleDatabase->handleCount += 1;
|
||||
newHandles = (struct saHandle *)realloc (handleDatabase->handles,
|
||||
sizeof (struct saHandle) * handleDatabase->handleCount);
|
||||
if (newHandles == 0) {
|
||||
return (SA_ERR_NO_MEMORY);
|
||||
}
|
||||
handleDatabase->handles = newHandles;
|
||||
}
|
||||
|
||||
instance = malloc (instanceSize);
|
||||
if (instance == 0) {
|
||||
return (SA_ERR_NO_MEMORY);
|
||||
}
|
||||
memset (instance, 0, instanceSize);
|
||||
|
||||
handleDatabase->handles[handle].state = SA_HANDLE_STATE_ACTIVE;
|
||||
|
||||
handleDatabase->handles[handle].instance = instance;
|
||||
|
||||
handleDatabase->handles[handle].refCount = 1;
|
||||
|
||||
*handleOut = handle;
|
||||
|
||||
return (SA_OK);
|
||||
}
|
||||
|
||||
|
||||
SaErrorT
|
||||
saHandleDestroy (
|
||||
struct saHandleDatabase *handleDatabase,
|
||||
unsigned int handle)
|
||||
{
|
||||
handleDatabase->handles[handle].state = SA_HANDLE_STATE_PENDINGREMOVAL;
|
||||
saHandleInstancePut (handleDatabase, handle);
|
||||
|
||||
return (SA_OK);
|
||||
}
|
||||
|
||||
|
||||
SaErrorT
|
||||
saHandleInstanceGet (
|
||||
struct saHandleDatabase *handleDatabase,
|
||||
unsigned int handle,
|
||||
void **instance)
|
||||
{
|
||||
if (handle >= handleDatabase->handleCount) {
|
||||
return (SA_ERR_BAD_HANDLE);
|
||||
}
|
||||
|
||||
if (handleDatabase->handles[handle].state != SA_HANDLE_STATE_ACTIVE) {
|
||||
return (SA_ERR_BAD_HANDLE);
|
||||
}
|
||||
|
||||
*instance = handleDatabase->handles[handle].instance;
|
||||
|
||||
handleDatabase->handles[handle].refCount += 1;
|
||||
|
||||
return (SA_OK);
|
||||
}
|
||||
|
||||
|
||||
SaErrorT
|
||||
saHandleInstancePut (
|
||||
struct saHandleDatabase *handleDatabase,
|
||||
unsigned int handle)
|
||||
{
|
||||
void *instance;
|
||||
|
||||
handleDatabase->handles[handle].refCount -= 1;
|
||||
assert (handleDatabase->handles[handle].refCount >= 0);
|
||||
|
||||
if (handleDatabase->handles[handle].refCount == 0) {
|
||||
instance = (handleDatabase->handles[handle].instance);
|
||||
if (handleDatabase->handleInstanceDestructor) {
|
||||
handleDatabase->handleInstanceDestructor (instance);
|
||||
}
|
||||
free (instance);
|
||||
memset (&handleDatabase->handles[handle], 0, sizeof (struct saHandle));
|
||||
}
|
||||
|
||||
return (SA_OK);
|
||||
}
|
87
exec/lck.c
87
exec/lck.c
@ -50,6 +50,7 @@
|
||||
#include "../include/ipc_lck.h"
|
||||
#include "../include/list.h"
|
||||
#include "../include/queue.h"
|
||||
#include "../lcr/lcr_comp.h"
|
||||
#include "aispoll.h"
|
||||
#include "mempool.h"
|
||||
#include "util.h"
|
||||
@ -59,6 +60,16 @@
|
||||
#define LOG_SERVICE LOG_SERVICE_LCK
|
||||
#include "print.h"
|
||||
|
||||
|
||||
enum lck_message_req_types {
|
||||
MESSAGE_REQ_EXEC_LCK_RESOURCEOPEN = 0,
|
||||
MESSAGE_REQ_EXEC_LCK_RESOURCECLOSE = 1,
|
||||
MESSAGE_REQ_EXEC_LCK_RESOURCELOCK = 2,
|
||||
MESSAGE_REQ_EXEC_LCK_RESOURCEUNLOCK = 3,
|
||||
MESSAGE_REQ_EXEC_LCK_RESOURCELOCKORPHAN = 4,
|
||||
MESSAGE_REQ_EXEC_LCK_LOCKPURGE = 5
|
||||
};
|
||||
|
||||
struct resource;
|
||||
struct resource_lock {
|
||||
SaLckLockModeT lock_mode;
|
||||
@ -256,6 +267,8 @@ static int (*lck_aisexec_handler_fns[]) (void *msg, struct in_addr source_addr,
|
||||
};
|
||||
|
||||
struct service_handler lck_service_handler = {
|
||||
.name = "openais distributed locking service B.01.01",
|
||||
.id = LCK_SERVICE,
|
||||
.libais_handlers = lck_libais_handlers,
|
||||
.libais_handlers_count = sizeof (lck_libais_handlers) / sizeof (struct libais_handler),
|
||||
.aisexec_handler_fns = lck_aisexec_handler_fns,
|
||||
@ -264,13 +277,53 @@ struct service_handler lck_service_handler = {
|
||||
.libais_init_two_fn = lck_init_two_fn,
|
||||
.libais_exit_fn = lck_exit_fn,
|
||||
.exec_init_fn = lck_exec_init_fn,
|
||||
.exec_dump_fn = 0,
|
||||
.sync_init = lck_recovery_initialize,
|
||||
.exec_dump_fn = NULL,
|
||||
.sync_init = NULL, // TODO lck_recovery_initialize,
|
||||
.sync_process = lck_recovery_process,
|
||||
.sync_activate = lck_recovery_activate,
|
||||
.sync_abort = lck_recovery_abort,
|
||||
};
|
||||
|
||||
#ifdef BUILD_DYNAMIC
|
||||
|
||||
struct service_handler *lck_get_handler_ver0 (void);
|
||||
|
||||
struct aisexec_iface_ver0 lck_service_handler_iface = {
|
||||
.test = NULL,
|
||||
.get_handler_ver0 = lck_get_handler_ver0
|
||||
};
|
||||
|
||||
struct lcr_iface openais_lck_ver0[1] = {
|
||||
{
|
||||
.name = "openais_lck",
|
||||
.version = 0,
|
||||
.versions_replace = 0,
|
||||
.versions_replace_count = 0,
|
||||
.dependencies = 0,
|
||||
.dependency_count = 0,
|
||||
.constructor = NULL,
|
||||
.destructor = NULL,
|
||||
.interfaces = (void **)&lck_service_handler_iface,
|
||||
}
|
||||
};
|
||||
|
||||
struct lcr_comp lck_comp_ver0 = {
|
||||
.iface_count = 1,
|
||||
.ifaces = openais_lck_ver0
|
||||
};
|
||||
|
||||
extern int lcr_comp_get (struct lcr_comp **component)
|
||||
{
|
||||
*component = &lck_comp_ver0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
struct service_handler *lck_get_handler_ver0 (void)
|
||||
{
|
||||
return (&lck_service_handler);
|
||||
}
|
||||
#endif /* BUILD_DYNAMIC */
|
||||
|
||||
/*
|
||||
* All data types used for executive messages
|
||||
*/
|
||||
@ -433,7 +486,8 @@ int lck_resource_close (struct resource *resource)
|
||||
|
||||
req_exec_lck_resourceclose.header.size =
|
||||
sizeof (struct req_exec_lck_resourceclose);
|
||||
req_exec_lck_resourceclose.header.id = MESSAGE_REQ_EXEC_LCK_RESOURCECLOSE;
|
||||
req_exec_lck_resourceclose.header.id =
|
||||
SERVICE_ID_MAKE (LCK_SERVICE, MESSAGE_REQ_EXEC_LCK_RESOURCECLOSE);
|
||||
|
||||
memcpy (&req_exec_lck_resourceclose.lockResourceName,
|
||||
&resource->name, sizeof (SaNameT));
|
||||
@ -456,7 +510,8 @@ void resource_lock_orphan (struct resource_lock *resource_lock)
|
||||
|
||||
req_exec_lck_resourcelockorphan.header.size =
|
||||
sizeof (struct req_exec_lck_resourcelockorphan);
|
||||
req_exec_lck_resourcelockorphan.header.id = MESSAGE_REQ_EXEC_LCK_RESOURCELOCKORPHAN;
|
||||
req_exec_lck_resourcelockorphan.header.id =
|
||||
SERVICE_ID_MAKE (LCK_SERVICE, MESSAGE_REQ_EXEC_LCK_RESOURCELOCKORPHAN);
|
||||
|
||||
memcpy (&req_exec_lck_resourcelockorphan.source,
|
||||
&resource_lock->callback_source,
|
||||
@ -1218,7 +1273,8 @@ static int message_handler_req_lib_lck_resourceopen (struct conn_info *conn_info
|
||||
|
||||
req_exec_lck_resourceopen.header.size =
|
||||
sizeof (struct req_exec_lck_resourceopen);
|
||||
req_exec_lck_resourceopen.header.id = MESSAGE_REQ_EXEC_LCK_RESOURCEOPEN;
|
||||
req_exec_lck_resourceopen.header.id =
|
||||
SERVICE_ID_MAKE (LCK_SERVICE, MESSAGE_REQ_EXEC_LCK_RESOURCEOPEN);
|
||||
|
||||
message_source_set (&req_exec_lck_resourceopen.source, conn_info);
|
||||
|
||||
@ -1251,7 +1307,8 @@ static int message_handler_req_lib_lck_resourceopenasync (struct conn_info *conn
|
||||
|
||||
req_exec_lck_resourceopen.header.size =
|
||||
sizeof (struct req_exec_lck_resourceopen);
|
||||
req_exec_lck_resourceopen.header.id = MESSAGE_REQ_EXEC_LCK_RESOURCEOPEN;
|
||||
req_exec_lck_resourceopen.header.id =
|
||||
SERVICE_ID_MAKE (LCK_SERVICE, MESSAGE_REQ_EXEC_LCK_RESOURCEOPEN);
|
||||
|
||||
message_source_set (&req_exec_lck_resourceopen.source, conn_info);
|
||||
|
||||
@ -1287,7 +1344,8 @@ static int message_handler_req_lib_lck_resourceclose (struct conn_info *conn_inf
|
||||
if (resource) {
|
||||
req_exec_lck_resourceclose.header.size =
|
||||
sizeof (struct req_exec_lck_resourceclose);
|
||||
req_exec_lck_resourceclose.header.id = MESSAGE_REQ_EXEC_LCK_RESOURCECLOSE;
|
||||
req_exec_lck_resourceclose.header.id =
|
||||
SERVICE_ID_MAKE (LCK_SERVICE, MESSAGE_REQ_EXEC_LCK_RESOURCECLOSE);
|
||||
|
||||
message_source_set (&req_exec_lck_resourceclose.source, conn_info);
|
||||
|
||||
@ -1327,7 +1385,8 @@ static int message_handler_req_lib_lck_resourcelock (struct conn_info *conn_info
|
||||
|
||||
req_exec_lck_resourcelock.header.size =
|
||||
sizeof (struct req_exec_lck_resourcelock);
|
||||
req_exec_lck_resourcelock.header.id = MESSAGE_REQ_EXEC_LCK_RESOURCELOCK;
|
||||
req_exec_lck_resourcelock.header.id =
|
||||
SERVICE_ID_MAKE (LCK_SERVICE, MESSAGE_REQ_EXEC_LCK_RESOURCELOCK);
|
||||
|
||||
message_source_set (&req_exec_lck_resourcelock.source, conn_info);
|
||||
|
||||
@ -1359,7 +1418,8 @@ static int message_handler_req_lib_lck_resourcelockasync (struct conn_info *conn
|
||||
|
||||
req_exec_lck_resourcelock.header.size =
|
||||
sizeof (struct req_exec_lck_resourcelock);
|
||||
req_exec_lck_resourcelock.header.id = MESSAGE_REQ_EXEC_LCK_RESOURCELOCK;
|
||||
req_exec_lck_resourcelock.header.id =
|
||||
SERVICE_ID_MAKE (LCK_SERVICE, MESSAGE_REQ_EXEC_LCK_RESOURCELOCK);
|
||||
|
||||
message_source_set (&req_exec_lck_resourcelock.source, conn_info);
|
||||
|
||||
@ -1390,7 +1450,8 @@ static int message_handler_req_lib_lck_resourceunlock (struct conn_info *conn_in
|
||||
|
||||
req_exec_lck_resourceunlock.header.size =
|
||||
sizeof (struct req_exec_lck_resourceunlock);
|
||||
req_exec_lck_resourceunlock.header.id = MESSAGE_REQ_EXEC_LCK_RESOURCEUNLOCK;
|
||||
req_exec_lck_resourceunlock.header.id =
|
||||
SERVICE_ID_MAKE (LCK_SERVICE, MESSAGE_REQ_EXEC_LCK_RESOURCEUNLOCK);
|
||||
|
||||
message_source_set (&req_exec_lck_resourceunlock.source, conn_info);
|
||||
|
||||
@ -1421,7 +1482,8 @@ static int message_handler_req_lib_lck_resourceunlockasync (struct conn_info *co
|
||||
|
||||
req_exec_lck_resourceunlock.header.size =
|
||||
sizeof (struct req_exec_lck_resourceunlock);
|
||||
req_exec_lck_resourceunlock.header.id = MESSAGE_REQ_EXEC_LCK_RESOURCEUNLOCK;
|
||||
req_exec_lck_resourceunlock.header.id =
|
||||
SERVICE_ID_MAKE (LCK_SERVICE, MESSAGE_REQ_EXEC_LCK_RESOURCEUNLOCK);
|
||||
|
||||
message_source_set (&req_exec_lck_resourceunlock.source, conn_info);
|
||||
|
||||
@ -1452,7 +1514,8 @@ static int message_handler_req_lib_lck_lockpurge (struct conn_info *conn_info, v
|
||||
|
||||
req_exec_lck_lockpurge.header.size =
|
||||
sizeof (struct req_exec_lck_lockpurge);
|
||||
req_exec_lck_lockpurge.header.id = MESSAGE_REQ_EXEC_LCK_LOCKPURGE;
|
||||
req_exec_lck_lockpurge.header.id =
|
||||
SERVICE_ID_MAKE (LCK_SERVICE, MESSAGE_REQ_EXEC_LCK_LOCKPURGE);
|
||||
|
||||
message_source_set (&req_exec_lck_lockpurge.source, conn_info);
|
||||
|
||||
|
231
exec/main.c
231
exec/main.c
@ -1,3 +1,4 @@
|
||||
//#define BUILD_DYNAMIC 1
|
||||
/*
|
||||
* vi: set autoindent tabstop=4 shiftwidth=4 :
|
||||
*
|
||||
@ -59,6 +60,7 @@
|
||||
#include "../include/saAis.h"
|
||||
#include "../include/list.h"
|
||||
#include "../include/queue.h"
|
||||
#include "../lcr/lcr_ifact.h"
|
||||
#include "poll.h"
|
||||
#include "totempg.h"
|
||||
#include "totemsrp.h"
|
||||
@ -75,6 +77,7 @@
|
||||
#include "ckpt.h"
|
||||
#include "evt.h"
|
||||
#include "lck.h"
|
||||
#include "msg.h"
|
||||
#include "cfg.h"
|
||||
#include "swab.h"
|
||||
|
||||
@ -89,22 +92,80 @@ int gid_valid = 0;
|
||||
/*
|
||||
* All service handlers in the AIS
|
||||
*/
|
||||
struct service_handler *ais_service_handlers[] = {
|
||||
&evs_service_handler,
|
||||
&clm_service_handler,
|
||||
&amf_service_handler,
|
||||
&ckpt_service_handler,
|
||||
&evt_service_handler,
|
||||
&lck_service_handler,
|
||||
&cfg_service_handler
|
||||
#ifdef BUILD_DYNAMIC
|
||||
struct dynamic_service {
|
||||
char *name;
|
||||
unsigned int ver;
|
||||
unsigned int handle;
|
||||
struct aisexec_iface_ver0 *iface_ver0;
|
||||
};
|
||||
|
||||
struct sync_callbacks sync_callbacks[5];
|
||||
/*
|
||||
* Still need to know the name of the service interface and version number
|
||||
*/
|
||||
struct dynamic_service dynamic_services[128] = {
|
||||
{
|
||||
.name = "openais_evs",
|
||||
.ver = 0,
|
||||
.handle = 0,
|
||||
.iface_ver0 = NULL
|
||||
},
|
||||
{
|
||||
.name = "openais_clm",
|
||||
.ver = 0,
|
||||
.handle = 0,
|
||||
.iface_ver0 = NULL
|
||||
},
|
||||
{
|
||||
.name = "openais_amf",
|
||||
.ver = 0,
|
||||
.handle = 0,
|
||||
.iface_ver0 = NULL
|
||||
},
|
||||
{
|
||||
.name = "openais_ckpt",
|
||||
.ver = 0,
|
||||
.handle = 0,
|
||||
.iface_ver0 = NULL
|
||||
},
|
||||
{
|
||||
.name = "openais_evt",
|
||||
.ver = 0,
|
||||
.handle = 0,
|
||||
.iface_ver0 = NULL
|
||||
},
|
||||
{
|
||||
.name = "openais_lck",
|
||||
.ver = 0,
|
||||
.handle = 0,
|
||||
.iface_ver0 = NULL
|
||||
},
|
||||
{
|
||||
.name = "openais_msg",
|
||||
.ver = 0,
|
||||
.handle = 0,
|
||||
.iface_ver0 = NULL
|
||||
},
|
||||
{
|
||||
.name = "openais_cfg",
|
||||
.ver = 0,
|
||||
.handle = 0,
|
||||
.iface_ver0 = NULL
|
||||
}
|
||||
};
|
||||
#endif /* BUILD_DYNAMIC */
|
||||
|
||||
static struct service_handler *ais_service_handlers[32];
|
||||
|
||||
int sync_callback_count;
|
||||
/*
|
||||
unsigned int aisexec_ifact_handle_ver0[32];
|
||||
|
||||
#define AIS_SERVICE_HANDLERS_COUNT 7
|
||||
#define AIS_SERVICE_HANDLER_AISEXEC_FUNCTIONS_MAX 50
|
||||
static struct aisexec_iface_ver0 *aisexec_iface_ver0[32];
|
||||
*/
|
||||
|
||||
static unsigned int service_handlers_count = 32;
|
||||
|
||||
SaClmClusterNodeT *(*main_clm_get_by_nodeid) (unsigned int node_id);
|
||||
|
||||
/*
|
||||
* IPC Initializers
|
||||
@ -134,6 +195,8 @@ enum e_ais_done {
|
||||
AIS_DONE_AMFCONFIGREAD = -11,
|
||||
};
|
||||
|
||||
extern int openais_amf_config_read (char **error_string);
|
||||
|
||||
static inline void ais_done (enum e_ais_done err)
|
||||
{
|
||||
log_printf (LOG_LEVEL_ERROR, "AIS Executive exiting.\n");
|
||||
@ -170,6 +233,7 @@ static inline struct conn_info *conn_info_create (int fd) {
|
||||
return (conn_info);
|
||||
}
|
||||
|
||||
#ifdef COMPILE_OUT
|
||||
static void sigusr2_handler (int num)
|
||||
{
|
||||
int i;
|
||||
@ -183,6 +247,7 @@ static void sigusr2_handler (int num)
|
||||
signal (SIGUSR2 ,sigusr2_handler);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct totem_ip_address *this_ip;
|
||||
struct totem_ip_address this_non_loopback_ip;
|
||||
@ -801,51 +866,22 @@ static int pool_sizes[] = { 0, 0, 0, 0, 0, 4096, 0, 1, 0, /* 256 */
|
||||
1024, 0, 1, 4096, 0, 0, 0, 0, /* 65536 */
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1 };
|
||||
|
||||
static int (*aisexec_handler_fns[AIS_SERVICE_HANDLER_AISEXEC_FUNCTIONS_MAX]) (void *msg, struct totem_ip_address *source_addr, int endian_conversion_required);
|
||||
static int aisexec_handler_fns_count = 0;
|
||||
|
||||
/*
|
||||
* Builds the handler table as an optimization
|
||||
*/
|
||||
static void aisexec_handler_fns_build (void)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
/*
|
||||
* Install sync handler function
|
||||
*/
|
||||
for (i = 0; i < AIS_SERVICE_HANDLERS_COUNT; i++) {
|
||||
for (j = 0; j < ais_service_handlers[i]->aisexec_handler_fns_count; j++) {
|
||||
aisexec_handler_fns[aisexec_handler_fns_count++] =
|
||||
ais_service_handlers[i]->aisexec_handler_fns[j];
|
||||
printf ("pos %d %x\n", aisexec_handler_fns_count - 1, ais_service_handlers[i]->aisexec_handler_fns[j]);
|
||||
}
|
||||
}
|
||||
log_printf (LOG_LEVEL_DEBUG, "built %d handler functions\n", aisexec_handler_fns_count);
|
||||
}
|
||||
|
||||
void sync_completed (void)
|
||||
static void openais_sync_completed (void)
|
||||
{
|
||||
}
|
||||
|
||||
void aisexec_sync_fns_build (void)
|
||||
static int openais_sync_callbacks_retrieve (int sync_id,
|
||||
struct sync_callbacks *callbacks)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < AIS_SERVICE_HANDLERS_COUNT; i++) {
|
||||
if (ais_service_handlers[i]->sync_init) {
|
||||
sync_callbacks[sync_callback_count].sync_init =
|
||||
ais_service_handlers[i]->sync_init;
|
||||
sync_callbacks[sync_callback_count].sync_process =
|
||||
ais_service_handlers[i]->sync_process;
|
||||
sync_callbacks[sync_callback_count].sync_activate =
|
||||
ais_service_handlers[i]->sync_activate;
|
||||
sync_callbacks[sync_callback_count].sync_abort =
|
||||
ais_service_handlers[i]->sync_abort;
|
||||
sync_callback_count++;
|
||||
}
|
||||
if (ais_service_handlers[sync_id] == NULL) {
|
||||
memset (callbacks, 0, sizeof (struct sync_callbacks));
|
||||
return (-1);
|
||||
}
|
||||
sync_register (sync_callbacks, sync_callback_count, sync_completed);
|
||||
callbacks->sync_init = ais_service_handlers[sync_id]->sync_init;
|
||||
callbacks->sync_process = ais_service_handlers[sync_id]->sync_process;
|
||||
callbacks->sync_activate = ais_service_handlers[sync_id]->sync_activate;
|
||||
callbacks->sync_abort = ais_service_handlers[sync_id]->sync_abort;
|
||||
return (0);
|
||||
}
|
||||
|
||||
char delivery_data[MESSAGE_SIZE_MAX];
|
||||
@ -860,6 +896,8 @@ static void deliver_fn (
|
||||
int res;
|
||||
int pos = 0;
|
||||
int i;
|
||||
int service;
|
||||
int fn_id;
|
||||
|
||||
/*
|
||||
* Build buffer without iovecs to make processing easier
|
||||
@ -883,8 +921,13 @@ static void deliver_fn (
|
||||
|
||||
// assert(iovec->iov_len == header->size);
|
||||
|
||||
res = aisexec_handler_fns[header->id](header, source_addr,
|
||||
endian_conversion_required);
|
||||
/*
|
||||
* Call the proper executive handler
|
||||
*/
|
||||
service = header->id >> 16;
|
||||
fn_id = header->id & 0xffff;
|
||||
res = ais_service_handlers[service]->aisexec_handler_fns[fn_id]
|
||||
(header, source_addr, endian_conversion_required);
|
||||
}
|
||||
|
||||
static struct memb_ring_id aisexec_ring_id;
|
||||
@ -907,8 +950,8 @@ static void confchg_fn (
|
||||
/*
|
||||
* Call configuration change for all services
|
||||
*/
|
||||
for (i = 0; i < AIS_SERVICE_HANDLERS_COUNT; i++) {
|
||||
if (ais_service_handlers[i]->confchg_fn) {
|
||||
for (i = 0; i < service_handlers_count; i++) {
|
||||
if (ais_service_handlers[i] && ais_service_handlers[i]->confchg_fn) {
|
||||
ais_service_handlers[i]->confchg_fn (configuration_type,
|
||||
member_list, member_list_entries,
|
||||
left_list, left_list_entries,
|
||||
@ -982,22 +1025,6 @@ static void aisexec_tty_detach (void)
|
||||
#undef DEBUG
|
||||
}
|
||||
|
||||
static void aisexec_service_handlers_init (struct openais_config *openais_config)
|
||||
{
|
||||
int i;
|
||||
/*
|
||||
* Initialize all services
|
||||
*/
|
||||
for (i = 0; i < AIS_SERVICE_HANDLERS_COUNT; i++) {
|
||||
if (ais_service_handlers[i]->exec_init_fn) {
|
||||
if (!ais_service_handlers[i]->exec_init_fn) {
|
||||
continue;
|
||||
}
|
||||
ais_service_handlers[i]->exec_init_fn (openais_config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void aisexec_libais_bind (int *server_fd)
|
||||
{
|
||||
int libais_server_fd;
|
||||
@ -1072,6 +1099,50 @@ void message_source_set (struct message_source *source, struct conn_info *conn_i
|
||||
|
||||
struct totem_logging_configuration totem_logging_configuration;
|
||||
|
||||
int service_handler_register (
|
||||
struct service_handler *handler,
|
||||
struct openais_config *config)
|
||||
{
|
||||
assert (ais_service_handlers[handler->id] == NULL);
|
||||
log_printf (LOG_LEVEL_NOTICE, "Registering service handler '%s'\n", handler->name);
|
||||
ais_service_handlers[handler->id] = handler;
|
||||
if (ais_service_handlers[handler->id]->exec_init_fn) {
|
||||
ais_service_handlers[handler->id]->exec_init_fn (config);
|
||||
}
|
||||
}
|
||||
|
||||
void default_services_register (struct openais_config *openais_config)
|
||||
{
|
||||
#ifdef BUILD_DYNAMIC
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
lcr_ifact_reference (
|
||||
&dynamic_services[i].handle,
|
||||
dynamic_services[i].name,
|
||||
dynamic_services[i].ver,
|
||||
(void **)&dynamic_services[i].iface_ver0,
|
||||
(void *)0);
|
||||
|
||||
service_handler_register (dynamic_services[i].iface_ver0->get_handler_ver0(), openais_config);
|
||||
}
|
||||
|
||||
#else /* NOT BUILD_DYNAMIC */
|
||||
/*
|
||||
* link everything together - better for debugging - smaller memory footprint
|
||||
*/
|
||||
|
||||
service_handler_register (&evs_service_handler, openais_config);
|
||||
service_handler_register (&clm_service_handler, openais_config);
|
||||
service_handler_register (&amf_service_handler, openais_config);
|
||||
service_handler_register (&ckpt_service_handler, openais_config);
|
||||
service_handler_register (&evt_service_handler, openais_config);
|
||||
service_handler_register (&lck_service_handler, openais_config);
|
||||
service_handler_register (&msg_service_handler, openais_config);
|
||||
service_handler_register (&cfg_service_handler, openais_config);
|
||||
#endif /* BUILD_DYNAMIC */
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int libais_server_fd;
|
||||
@ -1090,7 +1161,7 @@ int main (int argc, char **argv)
|
||||
|
||||
aisexec_poll_handle = poll_create ();
|
||||
|
||||
signal (SIGUSR2, sigusr2_handler);
|
||||
//TODO signal (SIGUSR2, sigusr2_handler);
|
||||
|
||||
/*
|
||||
* if totempg_initialize doesn't have root priveleges, it cannot
|
||||
@ -1167,6 +1238,10 @@ int main (int argc, char **argv)
|
||||
|
||||
this_ip = &openais_config.totem_config.interfaces[0].boundto;
|
||||
|
||||
default_services_register(&openais_config);
|
||||
|
||||
sync_register (openais_sync_callbacks_retrieve, openais_sync_completed);
|
||||
|
||||
/*
|
||||
* Drop root privleges to user 'ais'
|
||||
* TODO: Don't really need full root capabilities;
|
||||
@ -1177,10 +1252,6 @@ int main (int argc, char **argv)
|
||||
*/
|
||||
aisexec_priv_drop ();
|
||||
|
||||
aisexec_handler_fns_build ();
|
||||
|
||||
aisexec_sync_fns_build ();
|
||||
|
||||
aisexec_mempool_init ();
|
||||
|
||||
res = openais_amf_config_read (&error_string);
|
||||
@ -1189,14 +1260,12 @@ int main (int argc, char **argv)
|
||||
ais_done (AIS_DONE_AMFCONFIGREAD);
|
||||
}
|
||||
|
||||
aisexec_tty_detach ();
|
||||
|
||||
signal (SIGINT, sigintr_handler);
|
||||
|
||||
aisexec_service_handlers_init (&openais_config);
|
||||
|
||||
aisexec_libais_bind (&libais_server_fd);
|
||||
|
||||
aisexec_tty_detach ();
|
||||
|
||||
log_printf (LOG_LEVEL_NOTICE, "AIS Executive Service: started and ready to receive connections.\n");
|
||||
|
||||
/*
|
||||
|
40
exec/main.h
40
exec/main.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2004 MontaVista Software, Inc.
|
||||
* Copyright (c) 2002-2006 MontaVista Software, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -46,6 +46,7 @@
|
||||
#include "ckpt.h"
|
||||
#include "evt.h"
|
||||
#include "lck.h"
|
||||
#include "msg.h"
|
||||
|
||||
#ifndef AIS_EXEC_H_DEFINED
|
||||
#define AIS_EXEC_H_DEFINED
|
||||
@ -69,6 +70,8 @@ struct aisexec_ci {
|
||||
/*
|
||||
* Connection information for AIS connections
|
||||
*/
|
||||
|
||||
// TODO must make this dynamic
|
||||
struct ais_ci {
|
||||
struct sockaddr_un un_addr; /* address of AF_UNIX socket, MUST BE FIRST IN STRUCTURE */
|
||||
union {
|
||||
@ -79,6 +82,7 @@ struct ais_ci {
|
||||
struct libckpt_ci libckpt_ci;
|
||||
struct libevt_ci libevt_ci;
|
||||
struct liblck_ci liblck_ci;
|
||||
struct libmsg_ci libmsg_ci;
|
||||
} u;
|
||||
};
|
||||
|
||||
@ -113,39 +117,6 @@ struct conn_info {
|
||||
int should_exit_fn; /* Should call the exit function when closing this ipc */
|
||||
};
|
||||
|
||||
|
||||
enum nodeexec_message_types {
|
||||
MESSAGE_REQ_EXEC_EVS_MCAST = 0,
|
||||
MESSAGE_REQ_EXEC_CLM_NODEJOIN = 1,
|
||||
MESSAGE_REQ_EXEC_AMF_OPERATIONAL_STATE_COMP_SET = 2,
|
||||
MESSAGE_REQ_EXEC_AMF_PRESENCE_STATE_COMP_SET = 3,
|
||||
MESSAGE_REQ_EXEC_AMF_ADMINISTRATIVE_STATE_CSI_SET = 4,
|
||||
MESSAGE_REQ_EXEC_AMF_ADMINISTRATIVE_STATE_UNIT_SET = 5,
|
||||
MESSAGE_REQ_EXEC_AMF_ADMINISTRATIVE_STATE_GROUP_SET = 6,
|
||||
MESSAGE_REQ_EXEC_CKPT_CHECKPOINTOPEN = 7,
|
||||
MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE = 8,
|
||||
MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK = 9,
|
||||
MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONSET = 10,
|
||||
MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONEXPIRE = 11,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONCREATE = 12,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONDELETE = 13,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONEXPIRATIONTIMESET = 14,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONWRITE = 15,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONOVERWRITE = 16,
|
||||
MESSAGE_REQ_EXEC_CKPT_SECTIONREAD = 17,
|
||||
MESSAGE_REQ_EXEC_CKPT_SYNCHRONIZESTATE = 18,
|
||||
MESSAGE_REQ_EXEC_CKPT_SYNCHRONIZESECTION = 19,
|
||||
MESSAGE_REQ_EXEC_EVT_EVENTDATA = 20,
|
||||
MESSAGE_REQ_EXEC_EVT_CHANCMD = 21,
|
||||
MESSAGE_REQ_EXEC_EVT_RECOVERY_EVENTDATA = 22,
|
||||
MESSAGE_REQ_EXEC_LCK_RESOURCEOPEN = 23,
|
||||
MESSAGE_REQ_EXEC_LCK_RESOURCECLOSE = 24,
|
||||
MESSAGE_REQ_EXEC_LCK_RESOURCELOCK = 25,
|
||||
MESSAGE_REQ_EXEC_LCK_RESOURCEUNLOCK = 26,
|
||||
MESSAGE_REQ_EXEC_LCK_RESOURCELOCKORPHAN = 27,
|
||||
MESSAGE_REQ_EXEC_LCK_LOCKPURGE = 28
|
||||
};
|
||||
|
||||
extern struct totem_ip_address *this_ip;
|
||||
|
||||
extern struct totempg_group openais_group;
|
||||
@ -160,5 +131,6 @@ extern int message_source_is_local(struct message_source *source);
|
||||
|
||||
extern void message_source_set(struct message_source *source, struct conn_info *conn_info);
|
||||
|
||||
extern SaClmClusterNodeT *(*main_clm_get_by_nodeid) (unsigned int node_id);
|
||||
|
||||
#endif /* AIS_EXEC_H_DEFINED */
|
||||
|
1725
exec/msg.c
Normal file
1725
exec/msg.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2004 MontaVista Software, Inc.
|
||||
* Copyright (c) 2005 MontaVista Software, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -31,39 +31,19 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef HDB_H_DEFINED
|
||||
#define HDB_H_DEFINED
|
||||
|
||||
#include "../include/saAis.h"
|
||||
#include "../include/saCkpt.h"
|
||||
#include "aispoll.h"
|
||||
#include "totemsrp.h"
|
||||
|
||||
struct saHandleDatabase {
|
||||
unsigned int handleCount;
|
||||
struct saHandle *handles;
|
||||
pthread_mutex_t mutex;
|
||||
void (*handleInstanceDestructor) (void *);
|
||||
#ifndef MSG_H_DEFINED
|
||||
#define MSG_H_DEFINED
|
||||
|
||||
struct libmsg_ci {
|
||||
struct list_head queue_list;
|
||||
struct list_head queue_cleanup_list;
|
||||
};
|
||||
|
||||
extern SaErrorT
|
||||
saHandleCreate (
|
||||
struct saHandleDatabase *handleDatabase,
|
||||
int instanceSize,
|
||||
unsigned int *handleOut);
|
||||
extern struct service_handler msg_service_handler;
|
||||
|
||||
extern SaErrorT
|
||||
saHandleDestroy (
|
||||
struct saHandleDatabase *handleDatabase,
|
||||
unsigned int handle);
|
||||
|
||||
extern SaErrorT
|
||||
saHandleInstanceGet (
|
||||
struct saHandleDatabase *handleDatabase,
|
||||
unsigned int handle,
|
||||
void **instance);
|
||||
|
||||
extern SaErrorT
|
||||
saHandleInstancePut (
|
||||
struct saHandleDatabase *handleDatabase,
|
||||
unsigned int handle);
|
||||
|
||||
#endif /* HDB_H_DEFINED */
|
||||
#endif /* MSG_H_DEFINED */
|
@ -66,6 +66,7 @@ static char *log_services[] = {
|
||||
"[CKPT ]",
|
||||
"[EVT ]",
|
||||
"[LCK ]",
|
||||
"[MSG ]",
|
||||
"[EVS ]",
|
||||
"[SYNC ]",
|
||||
"[YKD ]"
|
||||
|
@ -62,9 +62,10 @@
|
||||
#define LOG_SERVICE_CKPT 5
|
||||
#define LOG_SERVICE_EVT 6
|
||||
#define LOG_SERVICE_LCK 7
|
||||
#define LOG_SERVICE_EVS 8
|
||||
#define LOG_SERVICE_SYNC 9
|
||||
#define LOG_SERVICE_YKD 10
|
||||
#define LOG_SERVICE_MSG 8
|
||||
#define LOG_SERVICE_EVS 9
|
||||
#define LOG_SERVICE_SYNC 10
|
||||
#define LOG_SERVICE_YKD 11
|
||||
|
||||
extern void internal_log_printf (int logclass, char *format, ...);
|
||||
|
||||
|
67
exec/sync.c
67
exec/sync.c
@ -67,9 +67,9 @@ struct barrier_data {
|
||||
|
||||
static struct memb_ring_id *sync_ring_id;
|
||||
|
||||
static struct sync_callbacks *sync_callbacks;
|
||||
static int (*sync_callbacks_retrieve) (int sync_id, struct sync_callbacks *callack);
|
||||
|
||||
static int sync_callback_count;
|
||||
static struct sync_callbacks sync_callbacks;
|
||||
|
||||
static int sync_processing = 0;
|
||||
|
||||
@ -93,7 +93,7 @@ static void sync_service_init (struct memb_ring_id *ring_id);
|
||||
|
||||
static int sync_service_process (enum totem_callback_token_type type, void *data);
|
||||
|
||||
static int sync_deliver_fn (
|
||||
static void sync_deliver_fn (
|
||||
struct totem_ip_address *source_addr,
|
||||
struct iovec *iovec,
|
||||
int iov_len,
|
||||
@ -152,7 +152,8 @@ void sync_start_init (struct memb_ring_id *ring_id)
|
||||
|
||||
static void sync_service_init (struct memb_ring_id *ring_id)
|
||||
{
|
||||
sync_callbacks[sync_recovery_index].sync_init ();
|
||||
// AA
|
||||
sync_callbacks.sync_init ();
|
||||
totempg_callback_token_destroy (&sync_callback_token_handle);
|
||||
|
||||
/*
|
||||
@ -181,6 +182,27 @@ static int sync_start_process (enum totem_callback_token_type type, void *data)
|
||||
return (0);
|
||||
}
|
||||
|
||||
void sync_callbacks_load (void)
|
||||
{
|
||||
int res;
|
||||
|
||||
// TODO rewrite this to get rid of the for (;;)
|
||||
for (;;) {
|
||||
res = sync_callbacks_retrieve (sync_recovery_index, &sync_callbacks);
|
||||
/*
|
||||
* No more service handlers have sync callbacks at this tie
|
||||
` */
|
||||
if (res == -1) {
|
||||
sync_processing = 0;
|
||||
break;
|
||||
}
|
||||
sync_recovery_index += 1;
|
||||
if (sync_callbacks.sync_init != NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int sync_service_process (enum totem_callback_token_type type, void *data)
|
||||
{
|
||||
int res;
|
||||
@ -191,28 +213,29 @@ static int sync_service_process (enum totem_callback_token_type type, void *data
|
||||
* If process returns 0, then its time to activate
|
||||
* and start the next service's synchronization
|
||||
*/
|
||||
res = sync_callbacks[sync_recovery_index].sync_process ();
|
||||
res = sync_callbacks.sync_process ();
|
||||
if (res != 0) {
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* This sync is complete so activate and start next service sync
|
||||
*/
|
||||
sync_callbacks[sync_recovery_index].sync_activate ();
|
||||
sync_callbacks.sync_activate ();
|
||||
totempg_callback_token_destroy (&sync_callback_token_handle);
|
||||
sync_recovery_index += 1;
|
||||
|
||||
if (sync_recovery_index > sync_callback_count) {
|
||||
sync_processing = 0;
|
||||
} else {
|
||||
sync_callbacks_load();
|
||||
|
||||
/*
|
||||
* if sync service found, execute it
|
||||
*/
|
||||
if (sync_processing && sync_callbacks.sync_init) {
|
||||
sync_start_init (ring_id);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void sync_register (
|
||||
struct sync_callbacks *callbacks,
|
||||
int callback_count,
|
||||
int (*callbacks_retrieve) (int sync_id, struct sync_callbacks *callack),
|
||||
void (*synchronization_completed) (void))
|
||||
{
|
||||
totempg_groups_initialize (
|
||||
@ -227,8 +250,7 @@ void sync_register (
|
||||
|
||||
ykd_init (sync_primary_callback_fn);
|
||||
|
||||
sync_callbacks = callbacks;
|
||||
sync_callback_count = callback_count;
|
||||
sync_callbacks_retrieve = callbacks_retrieve;
|
||||
sync_synchronization_completed = synchronization_completed;
|
||||
}
|
||||
|
||||
@ -270,7 +292,7 @@ void sync_primary_callback_fn (
|
||||
|
||||
static struct memb_ring_id deliver_ring_id;
|
||||
|
||||
int sync_deliver_fn (
|
||||
void sync_deliver_fn (
|
||||
struct totem_ip_address *source_addr,
|
||||
struct iovec *iovec,
|
||||
int iov_len,
|
||||
@ -292,8 +314,7 @@ int sync_deliver_fn (
|
||||
*/
|
||||
if (memcmp (&req_exec_sync_barrier_start->ring_id, sync_ring_id,
|
||||
sizeof (struct memb_ring_id)) != 0) {
|
||||
|
||||
return (0);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -324,13 +345,17 @@ int sync_deliver_fn (
|
||||
if (barrier_completed) {
|
||||
memcpy (barrier_data_process, barrier_data_confchg,
|
||||
sizeof (barrier_data_confchg));
|
||||
if (sync_recovery_index < sync_callback_count) {
|
||||
|
||||
sync_callbacks_load();
|
||||
|
||||
/*
|
||||
* if sync service found, execute it
|
||||
*/
|
||||
if (sync_processing && sync_callbacks.sync_init) {
|
||||
sync_service_init (&deliver_ring_id);
|
||||
} else {
|
||||
sync_processing = 0;
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
return;
|
||||
}
|
||||
|
||||
int sync_in_process (void)
|
||||
|
@ -47,8 +47,7 @@ struct sync_callbacks {
|
||||
};
|
||||
|
||||
void sync_register (
|
||||
struct sync_callbacks *callbacks,
|
||||
int callback_count,
|
||||
int (*sync_callbacks_retrieve) (int sync_id, struct sync_callbacks *callbacks),
|
||||
void (*synchronization_completed) (void));
|
||||
|
||||
int sync_in_process (void);
|
||||
|
@ -65,7 +65,7 @@
|
||||
#include "../include/queue.h"
|
||||
#include "../include/sq.h"
|
||||
#include "../include/list.h"
|
||||
#include "hdb.h"
|
||||
#include "../include/hdb.h"
|
||||
#include "swab.h"
|
||||
|
||||
#include "crypto.h"
|
||||
@ -191,10 +191,10 @@ struct work_item {
|
||||
/*
|
||||
* All instances in one database
|
||||
*/
|
||||
static struct saHandleDatabase totemnet_instance_database = {
|
||||
.handleCount = 0,
|
||||
.handles = 0,
|
||||
.handleInstanceDestructor = 0
|
||||
static struct hdb_handle_database totemnet_instance_database = {
|
||||
.handle_count = 0,
|
||||
.handles = 0,
|
||||
.iterator = 0
|
||||
};
|
||||
|
||||
static int loopback_determine (int family, struct totem_ip_address *bound_to);
|
||||
@ -591,19 +591,18 @@ int totemnet_finalize (
|
||||
totemnet_handle handle)
|
||||
{
|
||||
struct totemnet_instance *instance;
|
||||
SaErrorT error;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&totemnet_instance_database, handle,
|
||||
res = hdb_handle_get (&totemnet_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
worker_thread_group_exit (&instance->worker_thread_group);
|
||||
|
||||
saHandleInstancePut (&totemnet_instance_database, handle);
|
||||
hdb_handle_put (&totemnet_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (res);
|
||||
@ -1260,17 +1259,17 @@ int totemnet_initialize (
|
||||
void *context,
|
||||
struct totem_ip_address *iface_address))
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totemnet_instance *instance;
|
||||
unsigned int res;
|
||||
|
||||
error = saHandleCreate (&totemnet_instance_database,
|
||||
sizeof (struct totemnet_instance), handle);
|
||||
if (error != SA_OK) {
|
||||
res = hdb_handle_create (&totemnet_instance_database,
|
||||
sizeof (struct totemnet_instance), handle);
|
||||
if (res != 0) {
|
||||
goto error_exit;
|
||||
}
|
||||
error = saHandleInstanceGet (&totemnet_instance_database, *handle,
|
||||
res = hdb_handle_get (&totemnet_instance_database, *handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_destroy;
|
||||
}
|
||||
|
||||
@ -1333,11 +1332,11 @@ int totemnet_initialize (
|
||||
netif_down_check (instance);
|
||||
|
||||
error_exit:
|
||||
saHandleInstancePut (&totemnet_instance_database, *handle);
|
||||
hdb_handle_put (&totemnet_instance_database, *handle);
|
||||
return (0);
|
||||
|
||||
error_destroy:
|
||||
saHandleDestroy (&totemnet_instance_database, *handle);
|
||||
hdb_handle_destroy (&totemnet_instance_database, *handle);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@ -1345,20 +1344,19 @@ int totemnet_processor_count_set (
|
||||
totemnet_handle handle,
|
||||
int processor_count)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totemnet_instance *instance;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&totemnet_instance_database, handle,
|
||||
res = hdb_handle_get (&totemnet_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
instance->my_memb_entries = processor_count;
|
||||
|
||||
saHandleInstancePut (&totemnet_instance_database, handle);
|
||||
hdb_handle_put (&totemnet_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (res);
|
||||
@ -1366,16 +1364,15 @@ error_exit:
|
||||
|
||||
int totemnet_recv_flush (totemnet_handle handle)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totemnet_instance *instance;
|
||||
struct pollfd ufd;
|
||||
int nfds;
|
||||
int res = 0;
|
||||
unsigned int prio;
|
||||
|
||||
error = saHandleInstanceGet (&totemnet_instance_database, handle,
|
||||
res = hdb_handle_get (&totemnet_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
@ -1394,7 +1391,7 @@ int totemnet_recv_flush (totemnet_handle handle)
|
||||
|
||||
instance->flushing = 0;
|
||||
|
||||
saHandleInstancePut (&totemnet_instance_database, handle);
|
||||
hdb_handle_put (&totemnet_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (res);
|
||||
@ -1402,20 +1399,19 @@ error_exit:
|
||||
|
||||
int totemnet_send_flush (totemnet_handle handle)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totemnet_instance *instance;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&totemnet_instance_database, handle,
|
||||
res = hdb_handle_get (&totemnet_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
worker_thread_group_wait (&instance->worker_thread_group);
|
||||
|
||||
saHandleInstancePut (&totemnet_instance_database, handle);
|
||||
hdb_handle_put (&totemnet_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (res);
|
||||
@ -1427,20 +1423,19 @@ int totemnet_token_send (
|
||||
void *msg,
|
||||
int msg_len)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totemnet_instance *instance;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&totemnet_instance_database, handle,
|
||||
res = hdb_handle_get (&totemnet_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
totemnet_msg_send (instance, system_to, msg, msg_len);
|
||||
|
||||
saHandleInstancePut (&totemnet_instance_database, handle);
|
||||
hdb_handle_put (&totemnet_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (res);
|
||||
@ -1450,20 +1445,19 @@ int totemnet_mcast_flush_send (
|
||||
void *msg,
|
||||
int msg_len)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totemnet_instance *instance;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&totemnet_instance_database, handle,
|
||||
res = hdb_handle_get (&totemnet_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
totemnet_msg_send (instance, NULL, msg, msg_len);
|
||||
|
||||
saHandleInstancePut (&totemnet_instance_database, handle);
|
||||
hdb_handle_put (&totemnet_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (res);
|
||||
@ -1474,14 +1468,13 @@ int totemnet_mcast_noflush_send (
|
||||
struct iovec *iovec,
|
||||
int iov_len)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totemnet_instance *instance;
|
||||
struct work_item work_item;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&totemnet_instance_database, handle,
|
||||
res = hdb_handle_get (&totemnet_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
@ -1497,26 +1490,25 @@ int totemnet_mcast_noflush_send (
|
||||
totemnet_iovec_send (instance, iovec, iov_len);
|
||||
}
|
||||
|
||||
saHandleInstancePut (&totemnet_instance_database, handle);
|
||||
hdb_handle_put (&totemnet_instance_database, handle);
|
||||
error_exit:
|
||||
return (res);
|
||||
}
|
||||
extern int totemnet_iface_check (totemnet_handle handle)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totemnet_instance *instance;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&totemnet_instance_database, handle,
|
||||
res = hdb_handle_get (&totemnet_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
timer_function_netif_check_timeout (instance);
|
||||
|
||||
saHandleInstancePut (&totemnet_instance_database, handle);
|
||||
hdb_handle_put (&totemnet_instance_database, handle);
|
||||
error_exit:
|
||||
return (res);
|
||||
}
|
||||
|
105
exec/totempg.c
105
exec/totempg.c
@ -88,10 +88,10 @@
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../include/hdb.h"
|
||||
#include "totempg.h"
|
||||
#include "totemmrp.h"
|
||||
#include "totemsrp.h"
|
||||
#include "hdb.h"
|
||||
#include "swab.h"
|
||||
|
||||
#define min(a,b) ((a) < (b)) ? a : b
|
||||
@ -188,10 +188,10 @@ struct totempg_group_instance {
|
||||
int groups_cnt;
|
||||
};
|
||||
|
||||
static struct saHandleDatabase totempg_groups_instance_database = {
|
||||
.handleCount = 0,
|
||||
.handles = 0,
|
||||
.handleInstanceDestructor = 0
|
||||
static struct hdb_handle_database totempg_groups_instance_database = {
|
||||
.handle_count = 0,
|
||||
.handles = 0,
|
||||
.iterator = 0
|
||||
};
|
||||
|
||||
static int send_ok (int msg_size);
|
||||
@ -216,14 +216,14 @@ static inline void app_confchg_fn (
|
||||
struct memb_ring_id *ring_id)
|
||||
{
|
||||
int i;
|
||||
SaAisErrorT error;
|
||||
struct totempg_group_instance *instance;
|
||||
unsigned int res;
|
||||
|
||||
for (i = 0; i <= totempg_max_handle; i++) {
|
||||
error = saHandleInstanceGet (&totempg_groups_instance_database,
|
||||
res = hdb_handle_get (&totempg_groups_instance_database,
|
||||
i, (void *)&instance);
|
||||
|
||||
if (error == SA_OK) {
|
||||
if (res == 0) {
|
||||
if (instance->confchg_fn) {
|
||||
instance->confchg_fn (
|
||||
configuration_type,
|
||||
@ -236,7 +236,7 @@ static inline void app_confchg_fn (
|
||||
ring_id);
|
||||
}
|
||||
|
||||
saHandleInstancePut (&totempg_groups_instance_database, i);
|
||||
hdb_handle_put (&totempg_groups_instance_database, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -289,16 +289,16 @@ static inline void app_deliver_fn (
|
||||
int endian_conversion_required)
|
||||
{
|
||||
int i;
|
||||
SaAisErrorT error;
|
||||
struct totempg_group_instance *instance;
|
||||
struct iovec stripped_iovec;
|
||||
unsigned int adjust_iovec;
|
||||
unsigned int res;
|
||||
|
||||
for (i = 0; i <= totempg_max_handle; i++) {
|
||||
error = saHandleInstanceGet (&totempg_groups_instance_database,
|
||||
res = hdb_handle_get (&totempg_groups_instance_database,
|
||||
i, (void *)&instance);
|
||||
|
||||
if (error == SA_OK) {
|
||||
if (res == 0) {
|
||||
assert (iov_len == 1);
|
||||
if (group_matches (iovec, iov_len, instance->groups, instance->groups_cnt, &adjust_iovec)) {
|
||||
stripped_iovec.iov_len = iovec->iov_len - adjust_iovec;
|
||||
@ -310,7 +310,7 @@ static inline void app_deliver_fn (
|
||||
endian_conversion_required);
|
||||
}
|
||||
|
||||
saHandleInstancePut (&totempg_groups_instance_database, i);
|
||||
hdb_handle_put (&totempg_groups_instance_database, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -823,12 +823,12 @@ int totempg_groups_initialize (
|
||||
struct totem_ip_address *joined_list, int joined_list_entries,
|
||||
struct memb_ring_id *ring_id))
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totempg_group_instance *instance;
|
||||
unsigned int res;
|
||||
|
||||
error = saHandleCreate (&totempg_groups_instance_database,
|
||||
res = hdb_handle_create (&totempg_groups_instance_database,
|
||||
sizeof (struct totempg_group_instance), handle);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
@ -836,9 +836,9 @@ int totempg_groups_initialize (
|
||||
totempg_max_handle = *handle;
|
||||
}
|
||||
|
||||
error = saHandleInstanceGet (&totempg_groups_instance_database, *handle,
|
||||
res = hdb_handle_get (&totempg_groups_instance_database, *handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_destroy;
|
||||
}
|
||||
|
||||
@ -847,11 +847,11 @@ int totempg_groups_initialize (
|
||||
instance->groups = 0;
|
||||
instance->groups_cnt = 0;
|
||||
|
||||
saHandleInstancePut (&totempg_groups_instance_database, *handle);
|
||||
hdb_handle_put (&totempg_groups_instance_database, *handle);
|
||||
|
||||
return (0);
|
||||
error_destroy:
|
||||
saHandleDestroy (&totempg_groups_instance_database, *handle);
|
||||
hdb_handle_destroy (&totempg_groups_instance_database, *handle);
|
||||
|
||||
error_exit:
|
||||
return (-1);
|
||||
@ -862,13 +862,13 @@ int totempg_groups_join (
|
||||
struct totempg_group *groups,
|
||||
int group_cnt)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totempg_group_instance *instance;
|
||||
struct totempg_group *new_groups;
|
||||
unsigned int res;
|
||||
|
||||
error = saHandleInstanceGet (&totempg_groups_instance_database, handle,
|
||||
res = hdb_handle_get (&totempg_groups_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
@ -876,7 +876,7 @@ int totempg_groups_join (
|
||||
sizeof (struct totempg_group) *
|
||||
(instance->groups_cnt + group_cnt));
|
||||
if (new_groups == 0) {
|
||||
error = ENOMEM;
|
||||
res = ENOMEM;
|
||||
goto error_exit;
|
||||
}
|
||||
memcpy (&new_groups[instance->groups_cnt],
|
||||
@ -884,11 +884,11 @@ int totempg_groups_join (
|
||||
instance->groups = new_groups;
|
||||
instance->groups_cnt = instance->groups_cnt = group_cnt;
|
||||
|
||||
saHandleInstancePut (&totempg_groups_instance_database, handle);
|
||||
hdb_handle_put (&totempg_groups_instance_database, handle);
|
||||
return (0);
|
||||
|
||||
error_exit:
|
||||
return (error);
|
||||
return (res);
|
||||
}
|
||||
|
||||
int totempg_groups_leave (
|
||||
@ -896,19 +896,19 @@ int totempg_groups_leave (
|
||||
struct totempg_group *groups,
|
||||
int group_cnt)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totempg_group_instance *instance;
|
||||
unsigned int res;
|
||||
|
||||
error = saHandleInstanceGet (&totempg_groups_instance_database, handle,
|
||||
res = hdb_handle_get (&totempg_groups_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
saHandleInstancePut (&totempg_groups_instance_database, handle);
|
||||
hdb_handle_put (&totempg_groups_instance_database, handle);
|
||||
return (0);
|
||||
error_exit:
|
||||
return (error);
|
||||
return (res);
|
||||
}
|
||||
|
||||
#define MAX_IOVECS_FROM_APP 32
|
||||
@ -920,15 +920,15 @@ int totempg_groups_mcast_joined (
|
||||
int iov_len,
|
||||
int guarantee)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totempg_group_instance *instance;
|
||||
unsigned short group_len[MAX_GROUPS_PER_MSG + 1];
|
||||
struct iovec iovec_mcast[MAX_GROUPS_PER_MSG + 1 + MAX_IOVECS_FROM_APP];
|
||||
int i;
|
||||
unsigned int res;
|
||||
|
||||
error = saHandleInstanceGet (&totempg_groups_instance_database, handle,
|
||||
res = hdb_handle_get (&totempg_groups_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
@ -948,11 +948,11 @@ int totempg_groups_mcast_joined (
|
||||
iovec_mcast[i + instance->groups_cnt + 1].iov_base = iovec[i].iov_base;
|
||||
}
|
||||
|
||||
error = mcast_msg (iovec_mcast, iov_len + instance->groups_cnt + 1, guarantee);
|
||||
saHandleInstancePut (&totempg_groups_instance_database, handle);
|
||||
res = mcast_msg (iovec_mcast, iov_len + instance->groups_cnt + 1, guarantee);
|
||||
hdb_handle_put (&totempg_groups_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (error);
|
||||
return (res);
|
||||
}
|
||||
|
||||
int totempg_groups_send_ok_joined (
|
||||
@ -960,15 +960,14 @@ int totempg_groups_send_ok_joined (
|
||||
struct iovec *iovec,
|
||||
int iov_len)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totempg_group_instance *instance;
|
||||
unsigned int size = 0;
|
||||
unsigned int i;
|
||||
unsigned int res;
|
||||
|
||||
error = saHandleInstanceGet (&totempg_groups_instance_database, handle,
|
||||
res = hdb_handle_get (&totempg_groups_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
@ -981,11 +980,10 @@ int totempg_groups_send_ok_joined (
|
||||
|
||||
res = send_ok (size);
|
||||
|
||||
saHandleInstancePut (&totempg_groups_instance_database, handle);
|
||||
hdb_handle_put (&totempg_groups_instance_database, handle);
|
||||
|
||||
return (res);
|
||||
error_exit:
|
||||
return (error);
|
||||
return (res);
|
||||
}
|
||||
|
||||
int totempg_groups_mcast_groups (
|
||||
@ -996,15 +994,15 @@ int totempg_groups_mcast_groups (
|
||||
struct iovec *iovec,
|
||||
int iov_len)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totempg_group_instance *instance;
|
||||
unsigned short group_len[MAX_GROUPS_PER_MSG + 1];
|
||||
struct iovec iovec_mcast[MAX_GROUPS_PER_MSG + 1 + MAX_IOVECS_FROM_APP];
|
||||
int i;
|
||||
unsigned int res;
|
||||
|
||||
error = saHandleInstanceGet (&totempg_groups_instance_database, handle,
|
||||
res = hdb_handle_get (&totempg_groups_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
@ -1024,12 +1022,12 @@ int totempg_groups_mcast_groups (
|
||||
iovec_mcast[i + groups_cnt + 1].iov_base = iovec[i].iov_base;
|
||||
}
|
||||
|
||||
error = mcast_msg (iovec_mcast, iov_len + groups_cnt + 1, guarantee);
|
||||
res = mcast_msg (iovec_mcast, iov_len + groups_cnt + 1, guarantee);
|
||||
|
||||
saHandleInstancePut (&totempg_groups_instance_database, handle);
|
||||
hdb_handle_put (&totempg_groups_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (error);
|
||||
return (res);
|
||||
}
|
||||
|
||||
int totempg_groups_send_ok_groups (
|
||||
@ -1039,15 +1037,14 @@ int totempg_groups_send_ok_groups (
|
||||
struct iovec *iovec,
|
||||
int iov_len)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totempg_group_instance *instance;
|
||||
unsigned int size = 0;
|
||||
unsigned int i;
|
||||
unsigned int res;
|
||||
|
||||
error = saHandleInstanceGet (&totempg_groups_instance_database, handle,
|
||||
res = hdb_handle_get (&totempg_groups_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
@ -1060,9 +1057,9 @@ int totempg_groups_send_ok_groups (
|
||||
|
||||
res = send_ok (size);
|
||||
|
||||
saHandleInstancePut (&totempg_groups_instance_database, handle);
|
||||
hdb_handle_put (&totempg_groups_instance_database, handle);
|
||||
return (0);
|
||||
error_exit:
|
||||
return (error);
|
||||
return (res);
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@
|
||||
#include "../include/queue.h"
|
||||
#include "../include/sq.h"
|
||||
#include "../include/list.h"
|
||||
#include "hdb.h"
|
||||
#include "../include/hdb.h"
|
||||
#include "swab.h"
|
||||
#include "aispoll.h"
|
||||
#include "totemnet.h"
|
||||
@ -259,10 +259,10 @@ struct rrp_algo active_algo = {
|
||||
/*
|
||||
* All instances in one database
|
||||
*/
|
||||
static struct saHandleDatabase totemrrp_instance_database = {
|
||||
.handleCount = 0,
|
||||
.handles = 0,
|
||||
.handleInstanceDestructor = 0
|
||||
static struct hdb_handle_database totemrrp_instance_database = {
|
||||
.handle_count = 0,
|
||||
.handles = 0,
|
||||
.iterator = 0
|
||||
};
|
||||
|
||||
struct passive_instance *passive_instance_initialize (
|
||||
@ -573,19 +573,18 @@ int totemrrp_finalize (
|
||||
totemrrp_handle handle)
|
||||
{
|
||||
struct totemrrp_instance *instance;
|
||||
SaErrorT error;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&totemrrp_instance_database, handle,
|
||||
res = hdb_handle_get (&totemrrp_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
totemnet_finalize (instance->net_handle);
|
||||
|
||||
saHandleInstancePut (&totemrrp_instance_database, handle);
|
||||
hdb_handle_put (&totemrrp_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (res);
|
||||
@ -621,18 +620,18 @@ int totemrrp_initialize (
|
||||
unsigned int *token_is))
|
||||
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totemrrp_instance *instance;
|
||||
unsigned int res;
|
||||
int i;
|
||||
|
||||
error = saHandleCreate (&totemrrp_instance_database,
|
||||
res = hdb_handle_create (&totemrrp_instance_database,
|
||||
sizeof (struct totemrrp_instance), handle);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_exit;
|
||||
}
|
||||
error = saHandleInstanceGet (&totemrrp_instance_database, *handle,
|
||||
res = hdb_handle_get (&totemrrp_instance_database, *handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_destroy;
|
||||
}
|
||||
|
||||
@ -696,11 +695,11 @@ int totemrrp_initialize (
|
||||
totemnet_net_mtu_adjust (totem_config);
|
||||
|
||||
error_exit:
|
||||
saHandleInstancePut (&totemrrp_instance_database, *handle);
|
||||
hdb_handle_put (&totemrrp_instance_database, *handle);
|
||||
return (0);
|
||||
|
||||
error_destroy:
|
||||
saHandleDestroy (&totemrrp_instance_database, *handle);
|
||||
hdb_handle_destroy (&totemrrp_instance_database, *handle);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@ -708,13 +707,12 @@ int totemrrp_processor_count_set (
|
||||
totemrrp_handle handle,
|
||||
int processor_count)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totemrrp_instance *instance;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&totemrrp_instance_database, handle,
|
||||
res = hdb_handle_get (&totemrrp_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
@ -722,7 +720,7 @@ int totemrrp_processor_count_set (
|
||||
totemnet_processor_count_set (instance->net_handle, processor_count);
|
||||
instance->processor_count = processor_count;
|
||||
|
||||
saHandleInstancePut (&totemrrp_instance_database, handle);
|
||||
hdb_handle_put (&totemrrp_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (res);
|
||||
@ -730,20 +728,19 @@ error_exit:
|
||||
|
||||
int totemrrp_recv_flush (totemrrp_handle handle)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totemrrp_instance *instance;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&totemrrp_instance_database, handle,
|
||||
res = hdb_handle_get (&totemrrp_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
totemnet_recv_flush (instance->net_handle);
|
||||
|
||||
saHandleInstancePut (&totemrrp_instance_database, handle);
|
||||
hdb_handle_put (&totemrrp_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (res);
|
||||
@ -751,20 +748,19 @@ error_exit:
|
||||
|
||||
int totemrrp_send_flush (totemrrp_handle handle)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totemrrp_instance *instance;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&totemrrp_instance_database, handle,
|
||||
res = hdb_handle_get (&totemrrp_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
totemnet_send_flush (instance->net_handle);
|
||||
|
||||
saHandleInstancePut (&totemrrp_instance_database, handle);
|
||||
hdb_handle_put (&totemrrp_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (res);
|
||||
@ -776,20 +772,19 @@ int totemrrp_token_send (
|
||||
void *msg,
|
||||
int msg_len)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totemrrp_instance *instance;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&totemrrp_instance_database, handle,
|
||||
res = hdb_handle_get (&totemrrp_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
instance->rrp_algo->token_send (instance, system_to, msg, msg_len);
|
||||
|
||||
saHandleInstancePut (&totemrrp_instance_database, handle);
|
||||
hdb_handle_put (&totemrrp_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (res);
|
||||
@ -800,13 +795,12 @@ int totemrrp_mcast_flush_send (
|
||||
void *msg,
|
||||
int msg_len)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totemrrp_instance *instance;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&totemrrp_instance_database, handle,
|
||||
res = hdb_handle_get (&totemrrp_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
@ -814,7 +808,7 @@ int totemrrp_mcast_flush_send (
|
||||
// TODO this needs to return the result
|
||||
instance->rrp_algo->mcast_flush_send (instance, msg, msg_len);
|
||||
|
||||
saHandleInstancePut (&totemrrp_instance_database, handle);
|
||||
hdb_handle_put (&totemrrp_instance_database, handle);
|
||||
error_exit:
|
||||
return (res);
|
||||
}
|
||||
@ -824,13 +818,12 @@ int totemrrp_mcast_noflush_send (
|
||||
struct iovec *iovec,
|
||||
int iov_len)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totemrrp_instance *instance;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&totemrrp_instance_database, handle,
|
||||
res = hdb_handle_get (&totemrrp_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
@ -846,26 +839,25 @@ int totemrrp_mcast_noflush_send (
|
||||
instance->rrp_algo->mcast_noflush_send (instance, iovec, iov_len);
|
||||
}
|
||||
|
||||
saHandleInstancePut (&totemrrp_instance_database, handle);
|
||||
hdb_handle_put (&totemrrp_instance_database, handle);
|
||||
error_exit:
|
||||
return (res);
|
||||
}
|
||||
int totemrrp_iface_check (totemrrp_handle handle)
|
||||
{
|
||||
SaAisErrorT error;
|
||||
struct totemrrp_instance *instance;
|
||||
int res = 0;
|
||||
|
||||
error = saHandleInstanceGet (&totemrrp_instance_database, handle,
|
||||
res = hdb_handle_get (&totemrrp_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
res = ENOENT;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
totemnet_iface_check (instance->net_handle);
|
||||
|
||||
saHandleInstancePut (&totemrrp_instance_database, handle);
|
||||
hdb_handle_put (&totemrrp_instance_database, handle);
|
||||
error_exit:
|
||||
return (res);
|
||||
}
|
||||
|
@ -80,7 +80,7 @@
|
||||
#include "../include/queue.h"
|
||||
#include "../include/sq.h"
|
||||
#include "../include/list.h"
|
||||
#include "hdb.h"
|
||||
#include "../include/hdb.h"
|
||||
#include "swab.h"
|
||||
|
||||
#include "crypto.h"
|
||||
@ -545,10 +545,10 @@ void main_iface_change_fn (
|
||||
/*
|
||||
* All instances in one database
|
||||
*/
|
||||
static struct saHandleDatabase totemsrp_instance_database = {
|
||||
.handleCount = 0,
|
||||
.handles = 0,
|
||||
.handleInstanceDestructor = 0
|
||||
static struct hdb_handle_database totemsrp_instance_database = {
|
||||
.handle_count = 0,
|
||||
.handles = 0,
|
||||
.iterator = 0
|
||||
};
|
||||
struct message_handlers totemsrp_message_handlers = {
|
||||
6,
|
||||
@ -624,16 +624,16 @@ int totemsrp_initialize (
|
||||
struct memb_ring_id *ring_id))
|
||||
{
|
||||
struct totemsrp_instance *instance;
|
||||
SaErrorT error;
|
||||
unsigned int res;
|
||||
|
||||
error = saHandleCreate (&totemsrp_instance_database,
|
||||
res = hdb_handle_create (&totemsrp_instance_database,
|
||||
sizeof (struct totemsrp_instance), handle);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_exit;
|
||||
}
|
||||
error = saHandleInstanceGet (&totemsrp_instance_database, *handle,
|
||||
res = hdb_handle_get (&totemsrp_instance_database, *handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_destroy;
|
||||
}
|
||||
|
||||
@ -749,7 +749,7 @@ int totemsrp_initialize (
|
||||
return (0);
|
||||
|
||||
error_destroy:
|
||||
saHandleDestroy (&totemsrp_instance_database, *handle);
|
||||
hdb_handle_destroy (&totemsrp_instance_database, *handle);
|
||||
|
||||
error_exit:
|
||||
return (-1);
|
||||
@ -759,15 +759,15 @@ void totemsrp_finalize (
|
||||
totemsrp_handle handle)
|
||||
{
|
||||
struct totemsrp_instance *instance;
|
||||
SaErrorT error;
|
||||
unsigned int res;
|
||||
|
||||
error = saHandleInstanceGet (&totemsrp_instance_database, handle,
|
||||
res = hdb_handle_get (&totemsrp_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
saHandleInstancePut (&totemsrp_instance_database, handle);
|
||||
hdb_handle_put (&totemsrp_instance_database, handle);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1001,6 +1001,7 @@ static void memb_set_and (
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef CODE_COVERAGE
|
||||
static void memb_set_print (
|
||||
char *string,
|
||||
struct totem_ip_address *list,
|
||||
@ -1013,6 +1014,7 @@ static void memb_set_print (
|
||||
printf ("addr %s\n", totemip_print (&list[i]));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void reset_token_retransmit_timeout (struct totemsrp_instance *instance)
|
||||
{
|
||||
@ -1674,17 +1676,17 @@ static void memb_state_recovery_enter (
|
||||
int totemsrp_new_msg_signal (totemsrp_handle handle)
|
||||
{
|
||||
struct totemsrp_instance *instance;
|
||||
SaErrorT error;
|
||||
unsigned int res;
|
||||
|
||||
error = saHandleInstanceGet (&totemsrp_instance_database, handle,
|
||||
res = hdb_handle_get (&totemsrp_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
token_hold_cancel_send (instance);
|
||||
|
||||
saHandleInstancePut (&totemsrp_instance_database, handle);
|
||||
hdb_handle_put (&totemsrp_instance_database, handle);
|
||||
return (0);
|
||||
error_exit:
|
||||
return (-1);
|
||||
@ -1700,11 +1702,11 @@ int totemsrp_mcast (
|
||||
int j;
|
||||
struct message_item message_item;
|
||||
struct totemsrp_instance *instance;
|
||||
SaErrorT error;
|
||||
unsigned int res;
|
||||
|
||||
error = saHandleInstanceGet (&totemsrp_instance_database, handle,
|
||||
res = hdb_handle_get (&totemsrp_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
@ -1758,7 +1760,7 @@ printf ("queue full\n");
|
||||
instance->totemsrp_log_printf (instance->totemsrp_log_level_debug, "mcasted message added to pending queue\n");
|
||||
queue_item_add (&instance->new_message_queue, &message_item);
|
||||
|
||||
saHandleInstancePut (&totemsrp_instance_database, handle);
|
||||
hdb_handle_put (&totemsrp_instance_database, handle);
|
||||
return (0);
|
||||
|
||||
error_iovec:
|
||||
@ -1767,7 +1769,7 @@ error_iovec:
|
||||
}
|
||||
|
||||
error_mcast:
|
||||
saHandleInstancePut (&totemsrp_instance_database, handle);
|
||||
hdb_handle_put (&totemsrp_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (-1);
|
||||
@ -1780,17 +1782,17 @@ int totemsrp_avail (totemsrp_handle handle)
|
||||
{
|
||||
int avail;
|
||||
struct totemsrp_instance *instance;
|
||||
SaErrorT error;
|
||||
unsigned int res;
|
||||
|
||||
error = saHandleInstanceGet (&totemsrp_instance_database, handle,
|
||||
res = hdb_handle_get (&totemsrp_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
queue_avail (&instance->new_message_queue, &avail);
|
||||
|
||||
saHandleInstancePut (&totemsrp_instance_database, handle);
|
||||
hdb_handle_put (&totemsrp_instance_database, handle);
|
||||
|
||||
return (avail);
|
||||
|
||||
@ -2567,11 +2569,11 @@ int totemsrp_callback_token_create (
|
||||
{
|
||||
struct token_callback_instance *callback_handle;
|
||||
struct totemsrp_instance *instance;
|
||||
SaErrorT error;
|
||||
unsigned int res;
|
||||
|
||||
error = saHandleInstanceGet (&totemsrp_instance_database, handle,
|
||||
res = hdb_handle_get (&totemsrp_instance_database, handle,
|
||||
(void *)&instance);
|
||||
if (error != SA_OK) {
|
||||
if (res != 0) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
@ -2594,7 +2596,7 @@ int totemsrp_callback_token_create (
|
||||
break;
|
||||
}
|
||||
|
||||
saHandleInstancePut (&totemsrp_instance_database, handle);
|
||||
hdb_handle_put (&totemsrp_instance_database, handle);
|
||||
|
||||
error_exit:
|
||||
return (0);
|
||||
|
173
include/hdb.h
Normal file
173
include/hdb.h
Normal file
@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2006 MontaVista Software, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* 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
|
||||
* 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
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef HDB_H_DEFINED
|
||||
#define HDB_H_DEFINED
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
enum HDB_HANDLE_STATE {
|
||||
HDB_HANDLE_STATE_EMPTY,
|
||||
HDB_HANDLE_STATE_PENDINGREMOVAL,
|
||||
HDB_HANDLE_STATE_ACTIVE
|
||||
};
|
||||
|
||||
struct hdb_handle {
|
||||
int state;
|
||||
void *instance;
|
||||
int ref_count;
|
||||
};
|
||||
|
||||
struct hdb_handle_database {
|
||||
unsigned int handle_count;
|
||||
struct hdb_handle *handles;
|
||||
unsigned int iterator;
|
||||
};
|
||||
|
||||
static inline int hdb_handle_create (
|
||||
struct hdb_handle_database *handle_database,
|
||||
int instance_size,
|
||||
unsigned int *handle_id_out)
|
||||
{
|
||||
int handle;
|
||||
void *new_handles;
|
||||
int found = 0;
|
||||
void *instance;
|
||||
|
||||
for (handle = 0; handle < handle_database->handle_count; handle++) {
|
||||
if (handle_database->handles[handle].state == HDB_HANDLE_STATE_EMPTY) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == 0) {
|
||||
handle_database->handle_count += 1;
|
||||
new_handles = (struct hdb_handle *)realloc (handle_database->handles,
|
||||
sizeof (struct hdb_handle) * handle_database->handle_count);
|
||||
if (new_handles == 0) {
|
||||
return (-1);
|
||||
}
|
||||
handle_database->handles = new_handles;
|
||||
}
|
||||
|
||||
instance = (void *)malloc (instance_size);
|
||||
if (instance == 0) {
|
||||
return (-1);
|
||||
}
|
||||
memset (instance, 0, instance_size);
|
||||
|
||||
handle_database->handles[handle].state = HDB_HANDLE_STATE_ACTIVE;
|
||||
|
||||
handle_database->handles[handle].instance = instance;
|
||||
|
||||
handle_database->handles[handle].ref_count = 1;
|
||||
|
||||
*handle_id_out = handle;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static inline int hdb_handle_get (
|
||||
struct hdb_handle_database *handle_database,
|
||||
unsigned int handle,
|
||||
void **instance)
|
||||
{
|
||||
if (handle >= handle_database->handle_count) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (handle_database->handles[handle].state != HDB_HANDLE_STATE_ACTIVE) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
*instance = handle_database->handles[handle].instance;
|
||||
|
||||
handle_database->handles[handle].ref_count += 1;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static inline void hdb_handle_put (
|
||||
struct hdb_handle_database *handle_database,
|
||||
unsigned int handle)
|
||||
{
|
||||
handle_database->handles[handle].ref_count -= 1;
|
||||
assert (handle_database->handles[handle].ref_count >= 0);
|
||||
|
||||
if (handle_database->handles[handle].ref_count == 0) {
|
||||
free (handle_database->handles[handle].instance);
|
||||
memset (&handle_database->handles[handle], 0, sizeof (struct hdb_handle));
|
||||
}
|
||||
}
|
||||
|
||||
static inline void hdb_handle_destroy (
|
||||
struct hdb_handle_database *handle_database,
|
||||
unsigned int handle)
|
||||
{
|
||||
handle_database->handles[handle].state = HDB_HANDLE_STATE_PENDINGREMOVAL;
|
||||
hdb_handle_put (handle_database, handle);
|
||||
}
|
||||
|
||||
static inline void hdb_iterator_reset (
|
||||
struct hdb_handle_database *handle_database)
|
||||
{
|
||||
handle_database->iterator = 0;
|
||||
}
|
||||
|
||||
static inline int hdb_iterator_next (
|
||||
struct hdb_handle_database *handle_database,
|
||||
void **instance,
|
||||
unsigned int *handle)
|
||||
{
|
||||
int res = -1;
|
||||
|
||||
while (handle_database->iterator < handle_database->handle_count) {
|
||||
*handle = handle_database->iterator;
|
||||
res = hdb_handle_get (
|
||||
handle_database,
|
||||
handle_database->iterator,
|
||||
instance);
|
||||
|
||||
|
||||
handle_database->iterator += 1;
|
||||
if (res == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (res);
|
||||
}
|
||||
|
||||
#endif /* HDB_H_DEFINED */
|
@ -44,7 +44,8 @@ enum service_types {
|
||||
CKPT_SERVICE = 3,
|
||||
EVT_SERVICE = 4,
|
||||
LCK_SERVICE = 5,
|
||||
CFG_SERVICE = 6
|
||||
MSG_SERVICE = 6,
|
||||
CFG_SERVICE = 7
|
||||
};
|
||||
|
||||
enum req_init_types {
|
||||
|
266
include/ipc_msg.h
Normal file
266
include/ipc_msg.h
Normal file
@ -0,0 +1,266 @@
|
||||
/*
|
||||
* Copyright (c) 2005 MontaVista Software, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* 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
|
||||
* 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
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef IPC_MSG_H_DEFINED
|
||||
#define IPC_MSG_H_DEFINED
|
||||
|
||||
#include "saAis.h"
|
||||
#include "saMsg.h"
|
||||
#include "ipc_gen.h"
|
||||
|
||||
enum req_lib_msg_queue_types {
|
||||
MESSAGE_REQ_MSG_QUEUEOPEN = 0,
|
||||
MESSAGE_REQ_MSG_QUEUEOPENASYNC = 1,
|
||||
MESSAGE_REQ_MSG_QUEUECLOSE = 2,
|
||||
MESSAGE_REQ_MSG_QUEUESTATUSGET = 3,
|
||||
MESSAGE_REQ_MSG_QUEUEUNLINK = 4,
|
||||
MESSAGE_REQ_MSG_QUEUEGROUPCREATE = 5,
|
||||
MESSAGE_REQ_MSG_QUEUEGROUPINSERT = 6,
|
||||
MESSAGE_REQ_MSG_QUEUEGROUPREMOVE = 7,
|
||||
MESSAGE_REQ_MSG_QUEUEGROUPDELETE = 8,
|
||||
MESSAGE_REQ_MSG_QUEUEGROUPTRACK = 9,
|
||||
MESSAGE_REQ_MSG_QUEUEGROUPTRACKSTOP = 10,
|
||||
MESSAGE_REQ_MSG_MESSAGESEND = 11,
|
||||
MESSAGE_REQ_MSG_MESSAGEGET = 12,
|
||||
MESSAGE_REQ_MSG_MESSAGECANCEL = 13,
|
||||
MESSAGE_REQ_MSG_MESSAGESENDRECEIVE = 14,
|
||||
MESSAGE_REQ_MSG_MESSAGEREPLY = 15
|
||||
};
|
||||
|
||||
enum res_lib_msg_queue_types {
|
||||
MESSAGE_RES_MSG_QUEUEOPEN = 0,
|
||||
MESSAGE_RES_MSG_QUEUEOPENASYNC = 2,
|
||||
MESSAGE_RES_MSG_QUEUECLOSE = 3,
|
||||
MESSAGE_RES_MSG_QUEUESTATUSGET = 4,
|
||||
MESSAGE_RES_MSG_QUEUEUNLINK = 5,
|
||||
MESSAGE_RES_MSG_QUEUEGROUPCREATE = 6,
|
||||
MESSAGE_RES_MSG_QUEUEGROUPINSERT = 7,
|
||||
MESSAGE_RES_MSG_QUEUEGROUPREMOVE = 8,
|
||||
MESSAGE_RES_MSG_QUEUEGROUPDELETE = 9,
|
||||
MESSAGE_RES_MSG_QUEUEGROUPTRACK = 10,
|
||||
MESSAGE_RES_MSG_QUEUEGROUPTRACKSTOP = 11,
|
||||
MESSAGE_RES_MSG_MESSAGESEND = 12,
|
||||
MESSAGE_RES_MSG_MESSAGESENDASYNC = 13,
|
||||
MESSAGE_RES_MSG_MESSAGEGET = 14,
|
||||
MESSAGE_RES_MSG_MESSAGECANCEL = 15,
|
||||
MESSAGE_RES_MSG_MESSAGESENDRECEIVE = 16,
|
||||
MESSAGE_RES_MSG_MESSAGEREPLY = 17,
|
||||
MESSAGE_RES_MSG_MESSAGEREPLYASYNC = 18
|
||||
};
|
||||
|
||||
struct req_lib_msg_queueopen {
|
||||
struct req_header header;
|
||||
SaInvocationT invocation;
|
||||
SaNameT queueName;
|
||||
SaMsgQueueCreationAttributesT creationAttributes;
|
||||
int creationAttributesSet;
|
||||
SaMsgQueueOpenFlagsT openFlags;
|
||||
SaMsgQueueHandleT queueHandle;
|
||||
SaTimeT timeout;
|
||||
int async_call;
|
||||
};
|
||||
|
||||
struct res_lib_msg_queueopen {
|
||||
struct res_header header;
|
||||
SaMsgQueueHandleT queueHandle;
|
||||
struct message_source source;
|
||||
};
|
||||
|
||||
struct res_lib_msg_queueopenasync {
|
||||
struct res_header header;
|
||||
SaInvocationT invocation;
|
||||
SaMsgQueueHandleT queueHandle;
|
||||
struct message_source source;
|
||||
};
|
||||
|
||||
struct req_lib_msg_queueclose {
|
||||
struct req_header header;
|
||||
SaNameT queueName;
|
||||
SaMsgQueueHandleT queueHandle;
|
||||
};
|
||||
|
||||
struct res_lib_msg_queueclose {
|
||||
struct res_header header;
|
||||
};
|
||||
|
||||
struct req_lib_msg_queuestatusget {
|
||||
struct req_header header;
|
||||
SaNameT queueName;
|
||||
};
|
||||
|
||||
struct res_lib_msg_queuestatusget {
|
||||
struct res_header header;
|
||||
SaMsgQueueStatusT queueStatus;
|
||||
};
|
||||
|
||||
struct req_lib_msg_queueunlink {
|
||||
struct req_header header;
|
||||
SaNameT queueName;
|
||||
};
|
||||
|
||||
struct res_lib_msg_queueunlink {
|
||||
struct res_header header;
|
||||
};
|
||||
|
||||
struct req_lib_msg_queuegroupcreate {
|
||||
struct req_header header;
|
||||
SaNameT queueGroupName;
|
||||
SaMsgQueueGroupPolicyT queueGroupPolicy;
|
||||
};
|
||||
|
||||
struct res_lib_msg_queuegroupcreate {
|
||||
struct res_header header;
|
||||
};
|
||||
|
||||
struct req_lib_msg_queuegroupinsert {
|
||||
struct req_header header;
|
||||
SaNameT queueGroupName;
|
||||
SaNameT queueName;
|
||||
};
|
||||
|
||||
struct res_lib_msg_queuegroupinsert {
|
||||
struct res_header header;
|
||||
};
|
||||
|
||||
struct req_lib_msg_queuegroupremove {
|
||||
struct req_header header;
|
||||
SaNameT queueGroupName;
|
||||
SaNameT queueName;
|
||||
};
|
||||
|
||||
struct res_lib_msg_queuegroupremove {
|
||||
struct res_header header;
|
||||
};
|
||||
|
||||
struct req_lib_msg_queuegroupdelete {
|
||||
struct req_header header;
|
||||
SaNameT queueGroupName;
|
||||
};
|
||||
|
||||
struct res_lib_msg_queuegroupdelete {
|
||||
struct res_header header;
|
||||
};
|
||||
|
||||
struct req_lib_msg_queuegrouptrack {
|
||||
struct req_header header;
|
||||
SaNameT queueGroupName;
|
||||
SaUint8T trackFlags;
|
||||
};
|
||||
|
||||
struct res_lib_msg_queuegrouptrack {
|
||||
struct res_header header;
|
||||
};
|
||||
|
||||
struct req_lib_msg_queuegrouptrackstop {
|
||||
struct req_header header;
|
||||
SaNameT queueGroupName;
|
||||
};
|
||||
|
||||
struct res_lib_msg_queuegrouptrackstop {
|
||||
struct res_header header;
|
||||
};
|
||||
|
||||
struct req_lib_msg_messagesend {
|
||||
struct req_header header;
|
||||
SaInvocationT invocation;
|
||||
SaNameT destination;
|
||||
SaMsgMessageT message;
|
||||
SaTimeT timeout;
|
||||
SaMsgAckFlagsT ackFlags;
|
||||
int async_call;
|
||||
};
|
||||
|
||||
struct res_lib_msg_messagesend {
|
||||
struct res_header header;
|
||||
};
|
||||
|
||||
struct res_lib_msg_messagesendasync {
|
||||
struct res_header header;
|
||||
};
|
||||
|
||||
struct req_lib_msg_messageget {
|
||||
struct req_header header;
|
||||
SaNameT queueName;
|
||||
SaTimeT timeout;
|
||||
};
|
||||
|
||||
struct res_lib_msg_messageget {
|
||||
struct res_header header;
|
||||
SaTimeT sendTime;
|
||||
SaMsgSenderIdT senderId;
|
||||
SaMsgMessageT message;
|
||||
};
|
||||
|
||||
struct req_lib_msg_messagecancel {
|
||||
struct req_header header;
|
||||
SaNameT queueName;
|
||||
};
|
||||
|
||||
struct res_lib_msg_messagecancel {
|
||||
struct res_header header;
|
||||
};
|
||||
|
||||
struct req_lib_msg_messagesendreceive {
|
||||
struct req_header header;
|
||||
SaNameT destination;
|
||||
SaTimeT timeout;
|
||||
SaNameT queueName;
|
||||
SaMsgMessageT sendMessage;
|
||||
};
|
||||
|
||||
struct res_lib_msg_messagesendreceive {
|
||||
struct res_header header;
|
||||
SaTimeT replySendTime;
|
||||
SaMsgMessageT receiveMessage;
|
||||
};
|
||||
|
||||
struct req_lib_msg_messagereply {
|
||||
struct req_header header;
|
||||
SaInvocationT invocation;
|
||||
SaNameT queueName;
|
||||
SaNameT senderId;
|
||||
SaMsgMessageT replyMessage;
|
||||
SaTimeT timeout;
|
||||
SaMsgAckFlagsT ackFlags;
|
||||
int async_call;
|
||||
};
|
||||
|
||||
struct res_lib_msg_messagereply {
|
||||
struct res_header header;
|
||||
};
|
||||
|
||||
struct res_lib_msg_messagereplyasync {
|
||||
struct res_header header;
|
||||
};
|
||||
|
||||
#endif /* IPC_MSG_H_DEFINED */
|
284
include/saMsg.h
Normal file
284
include/saMsg.h
Normal file
@ -0,0 +1,284 @@
|
||||
/*
|
||||
* Copyright (c) 2005 MontaVista Software, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* 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
|
||||
* 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
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SAMSG_H_DEFINED
|
||||
#define SAMSG_H_DEFINED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef SaUint64T SaMsgHandleT;
|
||||
|
||||
typedef SaUint64T SaMsgQueueHandleT;
|
||||
|
||||
typedef SaUint64T SaMsgSenderIdT;
|
||||
|
||||
#define SA_MSG_MESSAGE_DELIVERED_ACK 0x1
|
||||
|
||||
typedef SaUint32T SaMsgAckFlagsT;
|
||||
|
||||
#define SA_MSG_QUEUE_PERSISTENT 0x1
|
||||
|
||||
typedef SaUint32T SaMsgQueueCreationFlagsT;
|
||||
|
||||
#define SA_MSG_MESSAGE_HIGHEST_PRIORITY 0
|
||||
#define SA_MSG_MESSAGE_LOWEST_PRIORITY 3
|
||||
|
||||
typedef struct {
|
||||
SaMsgQueueCreationFlagsT creationFlags;
|
||||
SaSizeT size[SA_MSG_MESSAGE_LOWEST_PRIORITY + 1];
|
||||
SaTimeT retentionTime;
|
||||
} SaMsgQueueCreationAttributesT;
|
||||
|
||||
typedef enum {
|
||||
SA_MSG_QUEUE_GROUP_ROUND_ROBIN = 1,
|
||||
SA_MSG_QUEUE_GROUP_LOCAL_ROUND_ROBIN = 2,
|
||||
SA_MSG_QUEUE_GROUP_LOCAL_BEST_QUEUE = 3,
|
||||
SA_MSG_QUEUE_GROUP_BROADCAST = 4
|
||||
} SaMsgQueueGroupPolicyT;
|
||||
|
||||
#define SA_MSG_QUEUE_CREATE 0x1
|
||||
#define SA_MSG_QUEUE_RECEIVE_CALLBACK 0x2
|
||||
#define SA_MSG_QUEUE_EMPTY 0x4
|
||||
|
||||
typedef SaUint32T SaMsgQueueOpenFlagsT;
|
||||
|
||||
typedef struct {
|
||||
SaSizeT queueSize;
|
||||
SaSizeT queueUsed;
|
||||
SaUint32T numberOfMessages;
|
||||
} SaMsgQueueUsageT;
|
||||
|
||||
typedef struct {
|
||||
SaMsgQueueCreationFlagsT creationFlags;
|
||||
SaTimeT retentionTime;
|
||||
SaTimeT closeTime;
|
||||
SaMsgQueueUsageT saMsgQueueUsage[SA_MSG_MESSAGE_LOWEST_PRIORITY + 1];
|
||||
} SaMsgQueueStatusT;
|
||||
|
||||
typedef enum {
|
||||
SA_MSG_QUEUE_GROUP_NO_CHANGE = 1,
|
||||
SA_MSG_QUEUE_GROUP_ADDED = 2,
|
||||
SA_MSG_QUEUE_GROUP_REMOVED = 3,
|
||||
SA_MSG_QUEUE_GROUP_STATE_CHANGED = 4
|
||||
} SaMsgQueueGroupChangesT;
|
||||
|
||||
typedef struct {
|
||||
SaNameT queueName;
|
||||
} SaMsgQueueGroupMemberT;
|
||||
|
||||
typedef struct {
|
||||
SaMsgQueueGroupMemberT member;
|
||||
SaMsgQueueGroupChangesT change;
|
||||
} SaMsgQueueGroupNotificationT;
|
||||
|
||||
typedef struct {
|
||||
SaUint32T numberOfItems;
|
||||
SaMsgQueueGroupNotificationT *notification;
|
||||
SaMsgQueueGroupPolicyT queueGroupPolicy;
|
||||
} SaMsgQueueGroupNotificationBufferT;
|
||||
|
||||
typedef struct {
|
||||
SaUint32T type;
|
||||
SaUint32T version;
|
||||
SaSizeT size;
|
||||
SaNameT *senderName;
|
||||
void *data;
|
||||
SaUint8T priority;
|
||||
} SaMsgMessageT;
|
||||
|
||||
typedef void (*SaMsgQueueOpenCallbackT) (
|
||||
SaInvocationT invocation,
|
||||
SaMsgQueueHandleT queueHandle,
|
||||
SaAisErrorT error);
|
||||
|
||||
typedef void (*SaMsgQueueGroupTrackCallbackT) (
|
||||
const SaNameT *queueGroupName,
|
||||
const SaMsgQueueGroupNotificationBufferT *notificationBuffer,
|
||||
SaUint32T numberOfMembers,
|
||||
SaAisErrorT error);
|
||||
|
||||
typedef void (*SaMsgMessageDeliveredCallbackT) (
|
||||
SaInvocationT invocation,
|
||||
SaAisErrorT error);
|
||||
|
||||
typedef void (*SaMsgMessageReceivedCallbackT) (
|
||||
SaMsgQueueHandleT queueHandle);
|
||||
|
||||
typedef struct {
|
||||
SaMsgQueueOpenCallbackT saMsgQueueOpenCallback;
|
||||
SaMsgQueueGroupTrackCallbackT saMsgQueueGroupTrackCallback;
|
||||
SaMsgMessageDeliveredCallbackT saMsgMessageDeliveredCallback;
|
||||
SaMsgMessageReceivedCallbackT saMsgMessageReceivedCallback;
|
||||
} SaMsgCallbacksT;
|
||||
|
||||
SaAisErrorT
|
||||
saMsgInitialize (
|
||||
SaMsgHandleT *msgHandle,
|
||||
const SaMsgCallbacksT *msgCallbacks,
|
||||
SaVersionT *version);
|
||||
|
||||
SaAisErrorT saMsgSelectionObjectGet (
|
||||
SaMsgHandleT msgHandle,
|
||||
SaSelectionObjectT *selectionObject);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgDispatch (
|
||||
SaMsgHandleT msgHandle,
|
||||
SaDispatchFlagsT dispatchFlags);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgFinalize (
|
||||
SaMsgHandleT msgHandle);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgQueueOpen (
|
||||
SaMsgHandleT msgHandle,
|
||||
const SaNameT *queueName,
|
||||
const SaMsgQueueCreationAttributesT *creationAttributes,
|
||||
SaMsgQueueOpenFlagsT openFlags,
|
||||
SaTimeT timeout,
|
||||
SaMsgQueueHandleT *queueHandle);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgQueueOpenAsync (
|
||||
SaMsgHandleT msgHandle,
|
||||
SaInvocationT invocation,
|
||||
const SaNameT *queueName,
|
||||
const SaMsgQueueCreationAttributesT *creationAttributes,
|
||||
SaMsgQueueOpenFlagsT openFlags);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgQueueClose (
|
||||
SaMsgQueueHandleT msgHandle);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgQueueStatusGet (
|
||||
SaMsgQueueHandleT msgHandle,
|
||||
const SaNameT *queueName,
|
||||
SaMsgQueueStatusT *queueStatus);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgQueueUnlink (
|
||||
SaMsgQueueHandleT msgHandle,
|
||||
const SaNameT *queueName);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgQueueGroupCreate (
|
||||
SaMsgHandleT msgHandle,
|
||||
const SaNameT *queueGroupName,
|
||||
SaMsgQueueGroupPolicyT queueGroupPolicy);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgQueueGroupInsert (
|
||||
SaMsgHandleT msgHandle,
|
||||
const SaNameT *queueGroupName,
|
||||
const SaNameT *queueName);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgQueueGroupRemove (
|
||||
SaMsgHandleT msgHandle,
|
||||
const SaNameT *queueGroupName,
|
||||
const SaNameT *queueName);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgQueueGroupDelete (
|
||||
SaMsgHandleT msgHandle,
|
||||
const SaNameT *queueGroupName);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgQueueGroupTrack (
|
||||
SaMsgHandleT msgHandle,
|
||||
const SaNameT *queueGroupName,
|
||||
SaUint8T trackFlags,
|
||||
SaMsgQueueGroupNotificationBufferT *notificationBuffer);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgQueueGroupTrackStop (
|
||||
SaMsgHandleT msgHandle,
|
||||
const SaNameT *queueGroupName);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgMessageSend (
|
||||
SaMsgHandleT msgHandle,
|
||||
const SaNameT *destination,
|
||||
const SaMsgMessageT *message,
|
||||
SaTimeT timeout);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgMessageSendAsync (
|
||||
SaMsgHandleT msgHandle,
|
||||
SaInvocationT invocation,
|
||||
const SaNameT *destination,
|
||||
const SaMsgMessageT *message,
|
||||
SaMsgAckFlagsT ackFlags);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgMessageGet (
|
||||
SaMsgQueueHandleT queueHandle,
|
||||
SaMsgMessageT *message,
|
||||
SaTimeT *sendTIme,
|
||||
SaMsgSenderIdT *senderId,
|
||||
SaTimeT timeout);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgMessageCancel (
|
||||
SaMsgQueueHandleT queueHandle);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgMessageSendReceive (
|
||||
SaMsgHandleT msgHandle,
|
||||
const SaNameT *destination,
|
||||
const SaMsgMessageT *sendMessage,
|
||||
SaMsgMessageT *receiveMessage,
|
||||
SaTimeT *replySendTime,
|
||||
SaTimeT timeout);
|
||||
|
||||
SaAisErrorT
|
||||
saMsgMessageReply (
|
||||
SaMsgHandleT msgHandle,
|
||||
const SaMsgMessageT *replyMessage,
|
||||
const SaMsgSenderIdT *senderId,
|
||||
SaTimeT timeout);
|
||||
|
||||
SaAisErrorT saMsgMessageREplyAsync (
|
||||
SaMsgHandleT msgHandle,
|
||||
SaInvocationT invocation,
|
||||
const SaMsgMessageT *replyMessage,
|
||||
const SaMsgSenderIdT *senderId,
|
||||
SaMsgAckFlagsT ackFlags);
|
||||
|
||||
#endif /* SALCK_H_DEFINED */
|
||||
|
61
lcr/Makefile
Executable file
61
lcr/Makefile
Executable file
@ -0,0 +1,61 @@
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# - Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# - Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# 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
|
||||
# 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
|
||||
# THE POSSIBILITY OF SUCH DAMAGE.
|
||||
# Production mode flags
|
||||
#CFLAGS = -O3 -Wall
|
||||
#LDFLAGS =
|
||||
|
||||
# Debug mode flags
|
||||
CFLAGS = -g -DDEBUG -Wall
|
||||
LDFLAGS = -g -L./
|
||||
|
||||
# Profile mode flags
|
||||
#CFLAGS = -O3 -pg -DDEBUG
|
||||
#LDFLAGS = -pg
|
||||
|
||||
# Code Coverage with lcov flgs
|
||||
#CFLAGS = -ftest-coverage -fprofile-arcs
|
||||
#LDFLAGS = -g
|
||||
|
||||
|
||||
CFLAGS += -fPIC
|
||||
|
||||
all:liblcr.a test uic libtest_a.lcrso libtest_b.lcrso
|
||||
|
||||
liblcr.a: lcr_ifact.o
|
||||
$(AR) -rc liblcr.a lcr_ifact.o
|
||||
|
||||
libtest_a.lcrso: libtest_a.o
|
||||
$(CC) -shared -Wl,-soname,libtest_b.lcrso libtest_a.o -o $@
|
||||
|
||||
libtest_b.lcrso: libtest_b.o
|
||||
$(CC) -shared -Wl,-soname,libtest_b.lcrso libtest_b.o -o $@
|
||||
|
||||
test: test.o uis.o lcr_ifact.o
|
||||
$(CC) $(LDFLAGS) test.o lcr_ifact.o uis.o -lpthread -ldl -o test
|
||||
|
||||
uic: uic.o
|
||||
$(CC) $(LDFLAGS) uic.o -o uic
|
||||
|
||||
clean:
|
||||
rm -f test libtest.so* *.o uic liblcr.so* liblcr.a *.lcrso *.da *.ba *.bb *.bbg
|
111
lcr/README.lcr
Normal file
111
lcr/README.lcr
Normal file
@ -0,0 +1,111 @@
|
||||
Live Component Replacement
|
||||
--------------------------
|
||||
All software is composed of components, which contain multiple software classes.
|
||||
Components generally depend upon other components and sometimes classes from
|
||||
other components.
|
||||
|
||||
Some components of openais are the evt service, the ckpt service, the clm
|
||||
service, the totem protocol, and others. If a defect is found in any of
|
||||
these components, the entire ais executive must be stopped, replaced, and
|
||||
restarted.
|
||||
|
||||
The lcr code formalizes the concept of components into dynamic libraries. A
|
||||
component may have multiple classes. Each class (the lcr code uses the word
|
||||
interface) may have multiple functions within the class. Each interface may
|
||||
depend upon other interfaces, and those interfaces are then loaded prior to the
|
||||
requested interface being referenced.
|
||||
|
||||
A list of shared objects is scanned each time an interface is requested to
|
||||
load via the following interface:
|
||||
|
||||
int lcr_ifact_reference (
|
||||
void **handle,
|
||||
char *iface_name,
|
||||
int version,
|
||||
void **interface,
|
||||
void *context);
|
||||
|
||||
The iface_name is the name of the interface, the version is the version,
|
||||
the void **interface is the list of functions returned once the interface
|
||||
has been dynamically loaded and referenced, and context is passed to the
|
||||
constructor and destructor.
|
||||
|
||||
The interface is loaded, the interface constructor is called, and the list
|
||||
of interfaces is returned back to the caller.
|
||||
|
||||
First the list of interfaces is described in an iface_list data structure:
|
||||
struct iface_list iface_list = {
|
||||
.iface1_func1 = iface1_func1,
|
||||
.iface1_func2 = iface1_func2,
|
||||
.iface1_func3 = iface1_func3,
|
||||
};
|
||||
iface1_func1 is a simple function call.
|
||||
|
||||
Then the lcr_iface data structure is defined for the c file:
|
||||
|
||||
struct lcr_iface iface1_ver0 = {
|
||||
.name = "iface1",
|
||||
.version = 0,
|
||||
.versions_replace = 0,
|
||||
.versions_replace_count = 0,
|
||||
.dependencies = 0,
|
||||
.dependency_count = 0,
|
||||
.constructor = iface1_constructor,
|
||||
.destructor = iface1_destructor,
|
||||
.interfaces = (void **)&iface_list,
|
||||
};
|
||||
|
||||
The name and version fields provide naming and versioning. The constructor
|
||||
and destructor functions execute at reference and release times. Finally
|
||||
the .interfaces type describes the list of functions used for the interface.
|
||||
|
||||
Next, an lcr_comp must be described:
|
||||
|
||||
struct lcr_comp test_comp = {
|
||||
.iface_count = 2,
|
||||
.ifaces = lcr_ifaces
|
||||
};
|
||||
|
||||
the iface count describes the number of interfaces within the component,
|
||||
and lcr_ifaces is an array of pointers to lcr_iface data types.
|
||||
|
||||
The final step is to export a function which tells the LCR referencing code
|
||||
about all of this static data that is setup:
|
||||
|
||||
extern int lcr_comp_get (struct lcr_comp **component)
|
||||
{
|
||||
lcr_ifaces[0] = iface1_ver0;
|
||||
lcr_ifaces[1] = iface1_ver1;
|
||||
*component = &test_comp;
|
||||
printf ("in lcr_comp_get for test component, address %p\n", &test_comp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
Now the component can be referenced and used in another application.
|
||||
int main ()
|
||||
{
|
||||
|
||||
.....
|
||||
|
||||
lcr_ifact_reference (
|
||||
&ifact_handle_ver0,
|
||||
"iface1",
|
||||
0, /* version 0 */
|
||||
(void **)&iface_ver0,
|
||||
(void *)0xdeadbeef);
|
||||
|
||||
iface_ver0->func1();
|
||||
iface_ver0->func2();
|
||||
iface_ver0->func3();
|
||||
}
|
||||
|
||||
|
||||
See libtest for a sample component and test.c for an example program which
|
||||
exercises the component.
|
||||
|
||||
On startup, a thread is created which listens for requests from the "uic"
|
||||
application. These requests are then processed by the lcr service which
|
||||
would execute a live replacement.
|
||||
|
||||
There is alot of stuff which isn't done, and if you want to try out this code,
|
||||
you will have to modify the path to the dynamic library that is loaded.
|
55
lcr/lcr_ckpt.h
Normal file
55
lcr/lcr_ckpt.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2006 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:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* 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
|
||||
* 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
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LCR_CKPT_H_DEFINED
|
||||
#define LCR_CKPT_H_DEFINED
|
||||
|
||||
/*
|
||||
* Write data of length data_len into the section name for ckpt_handle
|
||||
*/
|
||||
int lcr_ckpt_section_write (void *ckpt_handle, char *name, void *data, int data_len);
|
||||
|
||||
/*
|
||||
* Read the section name into data with data len. Returned in data_len is the
|
||||
* actual data read from ckpt_handle.
|
||||
*/
|
||||
int lcr_ckpt_section_read (void *ckpt_handle, char *name, void *data, int *data_len);
|
||||
|
||||
/*
|
||||
* Initialize the section iterator to the first section
|
||||
*/
|
||||
int lcr_ckpt_section_iterator_first (void *ckpt_handle);
|
||||
|
||||
/*
|
||||
* Get the current section, return it in name, and advance to next section
|
||||
*/
|
||||
int lcr_ckpt_section_iterator_next (void *ckpt_handle, char **name);
|
||||
|
||||
#endif /* LCR_CKPT_H_DEFINED */
|
61
lcr/lcr_comp.h
Normal file
61
lcr/lcr_comp.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2006 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:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* 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
|
||||
* 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
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LCR_COMP_H_DEFINED
|
||||
#define LCR_COMP_H_DEFINED
|
||||
|
||||
/*
|
||||
* LCR Interface
|
||||
*/
|
||||
struct lcr_iface {
|
||||
char *name; /* Name of the interface */
|
||||
int version; /* Version of this interface */
|
||||
int *versions_replace; /* Versions that this interface can replace */
|
||||
int versions_replace_count; /* Count of entries in version_replace */
|
||||
char **dependencies; /* Dependent interfaces */
|
||||
int dependency_count; /* Count of entires in dependencies */
|
||||
int (*constructor) (void *context); /* Constructor for this interface */
|
||||
void (*destructor) (void *context); /* Constructor for this interface */
|
||||
void **interfaces; /* List of functions in interface */
|
||||
};
|
||||
|
||||
/*
|
||||
* LCR Component
|
||||
*/
|
||||
struct lcr_comp {
|
||||
struct lcr_iface *ifaces; /* List of interfaces in this component */
|
||||
int iface_count; /* size of ifaces list */
|
||||
};
|
||||
/*
|
||||
* Exported by the component to retrieve the component information
|
||||
*/
|
||||
extern int lcr_comp_get (struct lcr_comp **component);
|
||||
|
||||
#endif /* LCR_COMP_H_DEFINED */
|
228
lcr/lcr_ifact.c
Normal file
228
lcr/lcr_ifact.c
Normal file
@ -0,0 +1,228 @@
|
||||
/*
|
||||
* Copyright (C) 2006 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:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* 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
|
||||
* 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
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <dlfcn.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include "lcr_comp.h"
|
||||
#include "lcr_ifact.h"
|
||||
#include "../include/hdb.h"
|
||||
|
||||
struct lcr_component_instance {
|
||||
struct lcr_iface *ifaces;
|
||||
int iface_count;
|
||||
void *dl_handle;
|
||||
int (*lcr_comp_get) (struct lcr_comp **component);
|
||||
int refcount;
|
||||
};
|
||||
|
||||
struct lcr_iface_instance {
|
||||
unsigned int component_handle;
|
||||
void *context;
|
||||
void (*destructor) (void *context);
|
||||
};
|
||||
|
||||
static struct hdb_handle_database lcr_component_instance_database = {
|
||||
.handle_count = 0,
|
||||
.handles = 0,
|
||||
.iterator = 0
|
||||
};
|
||||
|
||||
static struct hdb_handle_database lcr_iface_instance_database = {
|
||||
.handle_count = 0,
|
||||
.handles = 0,
|
||||
.iterator = 0
|
||||
};
|
||||
|
||||
static int lcr_select_so (const struct dirent *dirent)
|
||||
{
|
||||
unsigned int len;
|
||||
|
||||
len = strlen (dirent->d_name);
|
||||
|
||||
if (len > 6) {
|
||||
if (strcmp (".lcrso", dirent->d_name + len - 6) == 0) {
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int lcr_ifact_reference (
|
||||
unsigned int *iface_handle,
|
||||
char *iface_name,
|
||||
int version,
|
||||
void **iface,
|
||||
void *context)
|
||||
{
|
||||
struct lcr_component_instance *instance;
|
||||
struct lcr_component_instance new_component;
|
||||
struct lcr_iface_instance *iface_instance;
|
||||
int found = 0;
|
||||
int i;
|
||||
int res = -1;
|
||||
struct lcr_comp *comp;
|
||||
unsigned int component_handle;
|
||||
struct dirent **scandir_list;
|
||||
int scandir_entries;
|
||||
unsigned int libs_to_scan;
|
||||
char cwd[512];
|
||||
char dl_name[1024];
|
||||
|
||||
getcwd (cwd, sizeof (cwd));
|
||||
strcat (cwd, "/");
|
||||
|
||||
/*
|
||||
* Try to find interface in already loaded component
|
||||
*/
|
||||
hdb_iterator_reset (&lcr_component_instance_database);
|
||||
while (hdb_iterator_next (&lcr_component_instance_database,
|
||||
(void **)&instance, &component_handle) == 0) {
|
||||
|
||||
for (i = 0; i < instance->iface_count; i++) {
|
||||
if ((strcmp (instance->ifaces[i].name, iface_name) == 0) &&
|
||||
instance->ifaces[i].version == version) {
|
||||
|
||||
found = 1;
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
hdb_handle_put (&lcr_component_instance_database, component_handle);
|
||||
}
|
||||
|
||||
// TODO error checking in this code is weak
|
||||
/*
|
||||
* Find all *.lcrso files in the cwd
|
||||
*/
|
||||
scandir_entries = scandir(".", &scandir_list, lcr_select_so, alphasort);
|
||||
if (scandir_entries < 0)
|
||||
printf ("ERROR %d\n", errno);
|
||||
else
|
||||
/*
|
||||
* ELSE do the job
|
||||
*/
|
||||
for (libs_to_scan = 0; libs_to_scan < scandir_entries; libs_to_scan++) {
|
||||
|
||||
/*
|
||||
* Load objects, scan them, unload them if they are not a match
|
||||
*/
|
||||
fflush (stdout);
|
||||
sprintf (dl_name, "%s%s", cwd, scandir_list[libs_to_scan]->d_name);
|
||||
new_component.dl_handle =
|
||||
dlopen (dl_name, RTLD_NOW);
|
||||
if (new_component.dl_handle == 0) {
|
||||
printf ("Error loading interface %s\n", dlerror());
|
||||
return (-1);
|
||||
}
|
||||
new_component.lcr_comp_get =
|
||||
dlsym (new_component.dl_handle, "lcr_comp_get");
|
||||
if (new_component.lcr_comp_get == 0) {
|
||||
printf ("Error linking interface %s\n", dlerror());
|
||||
return (-1);
|
||||
}
|
||||
res = new_component.lcr_comp_get (&comp);
|
||||
new_component.ifaces = comp->ifaces;
|
||||
new_component.iface_count = comp->iface_count;
|
||||
|
||||
/*
|
||||
* Search loaded component for matching interface
|
||||
*/
|
||||
for (i = 0; i < new_component.iface_count; i++) {
|
||||
if ((strcmp (new_component.ifaces[i].name, iface_name) == 0) &&
|
||||
new_component.ifaces[i].version == version) {
|
||||
|
||||
hdb_handle_create (&lcr_component_instance_database,
|
||||
sizeof (struct lcr_component_instance),
|
||||
&component_handle);
|
||||
hdb_handle_get (&lcr_component_instance_database,
|
||||
component_handle, (void *)&instance);
|
||||
memcpy (instance, &new_component,
|
||||
sizeof (struct lcr_component_instance));
|
||||
|
||||
// printf("Found interface %s ver %d in dynamically loaded object %s\n", iface_name, version, dl_name);
|
||||
found = 1;
|
||||
free(scandir_list[libs_to_scan]);
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* No matching interfaces found, try next shared object
|
||||
*/
|
||||
dlclose (new_component.dl_handle);
|
||||
} /* scanning for loop */
|
||||
|
||||
/*
|
||||
* No matching interfaces found in all shared objects
|
||||
*/
|
||||
return (-1);
|
||||
found:
|
||||
|
||||
if (found) {
|
||||
*iface = instance->ifaces[i].interfaces;
|
||||
if (instance->ifaces[i].constructor) {
|
||||
instance->ifaces[i].constructor (context);
|
||||
}
|
||||
hdb_handle_create (&lcr_iface_instance_database,
|
||||
sizeof (struct lcr_iface_instance),
|
||||
iface_handle);
|
||||
hdb_handle_get (&lcr_iface_instance_database,
|
||||
*iface_handle, (void *)&iface_instance);
|
||||
iface_instance->component_handle = component_handle;
|
||||
iface_instance->context = context;
|
||||
iface_instance->destructor = instance->ifaces[i].destructor;
|
||||
res = 0;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int lcr_ifact_release (unsigned int handle)
|
||||
{
|
||||
struct lcr_iface_instance *iface_instance;
|
||||
int res = 0;
|
||||
|
||||
res = hdb_handle_get (&lcr_iface_instance_database,
|
||||
handle, (void *)&iface_instance);
|
||||
return (res);
|
||||
|
||||
if (iface_instance->destructor) {
|
||||
iface_instance->destructor (iface_instance->context);
|
||||
}
|
||||
|
||||
hdb_handle_put (&lcr_component_instance_database,
|
||||
iface_instance->component_handle);
|
||||
hdb_handle_put (&lcr_iface_instance_database, handle);
|
||||
hdb_handle_destroy (&lcr_iface_instance_database, handle);
|
||||
|
||||
return (res);
|
||||
}
|
44
lcr/lcr_ifact.h
Normal file
44
lcr/lcr_ifact.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2006 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:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* 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
|
||||
* 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
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LCR_IFACT_H_DEFINED
|
||||
#define LCR_IFACT_H_DEFINED
|
||||
|
||||
int lcr_ifact_reference (
|
||||
unsigned int *handle,
|
||||
char *iface_name,
|
||||
int version,
|
||||
void **interface,
|
||||
void *context);
|
||||
|
||||
int lcr_ifact_release (
|
||||
unsigned int handle);
|
||||
|
||||
#endif /* LCR_IFACT_H_DEFINED */
|
165
lcr/libtest_a.c
Normal file
165
lcr/libtest_a.c
Normal file
@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Copyright (C) 2006 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:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* 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
|
||||
* 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
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "lcr_comp.h"
|
||||
|
||||
/*
|
||||
* Version 0 of the interface
|
||||
*/
|
||||
int iface1_constructor (void *context);
|
||||
|
||||
int iface1_destructor (void *context);
|
||||
|
||||
void iface1_func1 (void);
|
||||
|
||||
void iface1_func2 (void);
|
||||
|
||||
void iface1_func3 (void);
|
||||
|
||||
/*
|
||||
* Version 1 of the interface
|
||||
*/
|
||||
int iface1_ver1_constructor (void *context);
|
||||
|
||||
int iface1_ver1_destructor (void *context);
|
||||
|
||||
void iface1_ver1_func1 (void);
|
||||
|
||||
void iface1_ver1_func2 (void);
|
||||
|
||||
void iface1_ver1_func3 (void);
|
||||
|
||||
struct iface_list {
|
||||
void (*iface1_func1)(void);
|
||||
void (*iface1_func2)(void);
|
||||
void (*iface1_func3)(void);
|
||||
};
|
||||
|
||||
struct iface_ver1_list {
|
||||
void (*iface1_ver1_func1)(void);
|
||||
void (*iface1_ver1_func2)(void);
|
||||
void (*iface1_ver1_func3)(void);
|
||||
};
|
||||
|
||||
struct iface_list iface_list = {
|
||||
.iface1_func1 = iface1_func1,
|
||||
.iface1_func2 = iface1_func2,
|
||||
.iface1_func3 = iface1_func3,
|
||||
};
|
||||
|
||||
struct iface_list iface_ver1_list = {
|
||||
.iface1_func1 = iface1_ver1_func1,
|
||||
.iface1_func2 = iface1_ver1_func2,
|
||||
.iface1_func3 = iface1_ver1_func3,
|
||||
};
|
||||
|
||||
struct lcr_iface iface1[2] = {
|
||||
/* version 0 */
|
||||
{
|
||||
.name = "A_iface1",
|
||||
.version = 0,
|
||||
.versions_replace = 0,
|
||||
.versions_replace_count = 0,
|
||||
.dependencies = 0,
|
||||
.dependency_count = 0,
|
||||
.constructor = iface1_constructor,
|
||||
.destructor = iface1_destructor,
|
||||
.interfaces = (void **)&iface_list,
|
||||
},
|
||||
/* version 1 */
|
||||
{
|
||||
.name = "A_iface1",
|
||||
.version = 1,
|
||||
.versions_replace = 0,
|
||||
.versions_replace_count = 0,
|
||||
.dependencies = 0,
|
||||
.dependency_count = 0,
|
||||
.constructor = iface1_ver1_constructor,
|
||||
.destructor = iface1_ver1_destructor,
|
||||
.interfaces = (void **)&iface_ver1_list
|
||||
}
|
||||
};
|
||||
|
||||
struct lcr_comp test_comp = {
|
||||
.iface_count = 2,
|
||||
.ifaces = iface1
|
||||
};
|
||||
|
||||
extern int lcr_comp_get (struct lcr_comp **component)
|
||||
{
|
||||
*component = &test_comp;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int iface1_constructor (void *context)
|
||||
{
|
||||
printf ("A - version 0 constructor context %p\n", context);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int iface1_destructor (void *context)
|
||||
{
|
||||
printf ("A - version 0 destructor context %p\n", context);
|
||||
return (0);
|
||||
}
|
||||
void iface1_func1 (void) {
|
||||
printf ("A - version 0 func1\n");
|
||||
}
|
||||
|
||||
void iface1_func2 (void) {
|
||||
printf ("A - version 0 func2\n");
|
||||
}
|
||||
|
||||
void iface1_func3 (void) {
|
||||
printf ("A - version 0 func3\n");
|
||||
}
|
||||
|
||||
int iface1_ver1_constructor (void *context)
|
||||
{
|
||||
printf ("A - version 1 constructor context %p\n", context);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int iface1_ver1_destructor (void *context)
|
||||
{
|
||||
printf ("A - version 1 destructor context %p\n", context);
|
||||
return (0);
|
||||
}
|
||||
void iface1_ver1_func1 (void) {
|
||||
printf ("A - version 1 func1\n");
|
||||
}
|
||||
|
||||
void iface1_ver1_func2 (void) {
|
||||
printf ("A - version 1 func2\n");
|
||||
}
|
||||
|
||||
void iface1_ver1_func3 (void) {
|
||||
printf ("A - version 1 func3\n");
|
||||
}
|
169
lcr/libtest_b.c
Normal file
169
lcr/libtest_b.c
Normal file
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright (C) 2006 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:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* 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
|
||||
* 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
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "lcr_comp.h"
|
||||
|
||||
/*
|
||||
* Version 0 of the interface
|
||||
*/
|
||||
int iface1_constructor (void *context);
|
||||
|
||||
int iface1_destructor (void *context);
|
||||
|
||||
void iface1_func1 (void);
|
||||
|
||||
void iface1_func2 (void);
|
||||
|
||||
void iface1_func3 (void);
|
||||
|
||||
/*
|
||||
* Version 1 of the interface
|
||||
*/
|
||||
int iface1_ver1_constructor (void *context);
|
||||
|
||||
int iface1_ver1_destructor (void *context);
|
||||
|
||||
void iface1_ver1_func1 (void);
|
||||
|
||||
void iface1_ver1_func2 (void);
|
||||
|
||||
void iface1_ver1_func3 (void);
|
||||
|
||||
struct iface_list {
|
||||
void (*iface1_func1)(void);
|
||||
void (*iface1_func2)(void);
|
||||
void (*iface1_func3)(void);
|
||||
};
|
||||
|
||||
struct iface_ver1_list {
|
||||
void (*iface1_ver1_func1)(void);
|
||||
void (*iface1_ver1_func2)(void);
|
||||
void (*iface1_ver1_func3)(void);
|
||||
};
|
||||
|
||||
struct iface_list iface_list = {
|
||||
.iface1_func1 = iface1_func1,
|
||||
.iface1_func2 = iface1_func2,
|
||||
.iface1_func3 = iface1_func3,
|
||||
};
|
||||
|
||||
struct iface_list iface_ver1_list = {
|
||||
.iface1_func1 = iface1_ver1_func1,
|
||||
.iface1_func2 = iface1_ver1_func2,
|
||||
.iface1_func3 = iface1_ver1_func3,
|
||||
};
|
||||
|
||||
struct lcr_iface iface1[2]= {
|
||||
/*
|
||||
* Version 0
|
||||
*/
|
||||
{
|
||||
.name = "B_iface1",
|
||||
.version = 0,
|
||||
.versions_replace = 0,
|
||||
.versions_replace_count = 0,
|
||||
.dependencies = 0,
|
||||
.dependency_count = 0,
|
||||
.constructor = iface1_constructor,
|
||||
.destructor = iface1_destructor,
|
||||
.interfaces = (void **)&iface_list,
|
||||
},
|
||||
/*
|
||||
* Version 1
|
||||
*/
|
||||
{
|
||||
.name = "B_iface1",
|
||||
.version = 1,
|
||||
.versions_replace = 0,
|
||||
.versions_replace_count = 0,
|
||||
.dependencies = 0,
|
||||
.dependency_count = 0,
|
||||
.constructor = iface1_ver1_constructor,
|
||||
.destructor = iface1_ver1_destructor,
|
||||
.interfaces = (void **)&iface_ver1_list
|
||||
}
|
||||
};
|
||||
|
||||
struct lcr_comp test_comp = {
|
||||
.iface_count = 2,
|
||||
.ifaces = iface1
|
||||
};
|
||||
|
||||
extern int lcr_comp_get (struct lcr_comp **component)
|
||||
{
|
||||
*component = &test_comp;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int iface1_constructor (void *context)
|
||||
{
|
||||
printf ("B - version 0 constructor context %p\n", context);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int iface1_destructor (void *context)
|
||||
{
|
||||
printf ("B - version 0 destructor context %p\n", context);
|
||||
return (0);
|
||||
}
|
||||
void iface1_func1 (void) {
|
||||
printf ("B - version 0 func1\n");
|
||||
}
|
||||
|
||||
void iface1_func2 (void) {
|
||||
printf ("B - version 0 func2\n");
|
||||
}
|
||||
|
||||
void iface1_func3 (void) {
|
||||
printf ("B - version 0 func3\n");
|
||||
}
|
||||
|
||||
int iface1_ver1_constructor (void *context)
|
||||
{
|
||||
printf ("B - version 1 constructor context %p\n", context);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int iface1_ver1_destructor (void *context)
|
||||
{
|
||||
printf ("B - version 1 destructor context %p\n", context);
|
||||
return (0);
|
||||
}
|
||||
void iface1_ver1_func1 (void) {
|
||||
printf ("B - version 1 func1\n");
|
||||
}
|
||||
|
||||
void iface1_ver1_func2 (void) {
|
||||
printf ("B - version 1 func2\n");
|
||||
}
|
||||
|
||||
void iface1_ver1_func3 (void) {
|
||||
printf ("B - version 1 func3\n");
|
||||
}
|
106
lcr/test.c
Normal file
106
lcr/test.c
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2006 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:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* 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
|
||||
* 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
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include "lcr_ifact.h"
|
||||
|
||||
struct iface {
|
||||
void (*func1) (void);
|
||||
void (*func2) (void);
|
||||
void (*func3) (void);
|
||||
};
|
||||
|
||||
int main (void) {
|
||||
unsigned int a_ifact_handle_ver0;
|
||||
unsigned int b_ifact_handle_ver0;
|
||||
struct iface *a_iface_ver0;
|
||||
struct iface *a_iface_ver1;
|
||||
|
||||
unsigned int a_ifact_handle_ver1;
|
||||
unsigned int b_ifact_handle_ver1;
|
||||
struct iface *b_iface_ver0;
|
||||
struct iface *b_iface_ver1;
|
||||
|
||||
/*
|
||||
* Reference version 0 and 1 of A and B interfaces
|
||||
*/
|
||||
lcr_ifact_reference (
|
||||
&a_ifact_handle_ver0,
|
||||
"A_iface1",
|
||||
0, /* version 0 */
|
||||
(void **)&a_iface_ver0,
|
||||
(void *)0xaaaa0000);
|
||||
|
||||
lcr_ifact_reference (
|
||||
&b_ifact_handle_ver0,
|
||||
"B_iface1",
|
||||
0, /* version 0 */
|
||||
(void **)&b_iface_ver0,
|
||||
(void *)0xbbbb00000);
|
||||
|
||||
lcr_ifact_reference (
|
||||
&a_ifact_handle_ver1,
|
||||
"A_iface1",
|
||||
1, /* version 1 */
|
||||
(void **)&a_iface_ver1,
|
||||
(void *)0xaaaa1111);
|
||||
|
||||
lcr_ifact_reference (
|
||||
&b_ifact_handle_ver1,
|
||||
"B_iface1",
|
||||
1, /* version 1 */
|
||||
(void **)&b_iface_ver1,
|
||||
(void *)0xbbbb1111);
|
||||
|
||||
a_iface_ver0->func1();
|
||||
a_iface_ver0->func2();
|
||||
a_iface_ver0->func3();
|
||||
|
||||
lcr_ifact_release (a_ifact_handle_ver0);
|
||||
|
||||
a_iface_ver1->func1();
|
||||
a_iface_ver1->func2();
|
||||
a_iface_ver1->func3();
|
||||
|
||||
lcr_ifact_release (a_ifact_handle_ver1);
|
||||
|
||||
b_iface_ver0->func1();
|
||||
b_iface_ver0->func2();
|
||||
b_iface_ver0->func3();
|
||||
|
||||
lcr_ifact_release (b_ifact_handle_ver0);
|
||||
|
||||
b_iface_ver1->func1();
|
||||
b_iface_ver1->func2();
|
||||
b_iface_ver1->func3();
|
||||
|
||||
lcr_ifact_release (b_ifact_handle_ver1);
|
||||
|
||||
return (0);
|
||||
}
|
122
lcr/uic.c
Executable file
122
lcr/uic.c
Executable file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (C) 2006 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:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* 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
|
||||
* 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
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/uio.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <sched.h>
|
||||
#include <time.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/poll.h>
|
||||
|
||||
char *socketname = "lcr.uis.socket";
|
||||
|
||||
int uic_connect (int *fd)
|
||||
{
|
||||
int res;
|
||||
struct sockaddr_un addr;
|
||||
|
||||
memset (&addr, 0, sizeof (struct sockaddr_un));
|
||||
addr.sun_family = PF_UNIX;
|
||||
strcpy (addr.sun_path + 1, "lcr.socket");
|
||||
*fd = socket (PF_UNIX, SOCK_STREAM, 0);
|
||||
if (*fd == -1) {
|
||||
return -errno;
|
||||
}
|
||||
res = connect (*fd, (struct sockaddr *)&addr, sizeof (addr));
|
||||
if (res == -1) {
|
||||
return -errno;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct req_msg {
|
||||
int len;
|
||||
char msg[0];
|
||||
};
|
||||
|
||||
int uic_msg_send (int fd, char *msg)
|
||||
{
|
||||
struct msghdr msg_send;
|
||||
struct iovec iov_send[2];
|
||||
struct req_msg req_msg;
|
||||
int res;
|
||||
|
||||
req_msg.len = strlen (msg) + 1;
|
||||
iov_send[0].iov_base = (void *)&req_msg;
|
||||
iov_send[0].iov_len = sizeof (struct req_msg);
|
||||
iov_send[1].iov_base = (void *)msg;
|
||||
iov_send[1].iov_len = req_msg.len;
|
||||
|
||||
msg_send.msg_iov = iov_send;
|
||||
msg_send.msg_iovlen = 2;
|
||||
msg_send.msg_name = 0;
|
||||
msg_send.msg_namelen = 0;
|
||||
msg_send.msg_control = 0;
|
||||
msg_send.msg_controllen = 0;
|
||||
msg_send.msg_flags = 0;
|
||||
|
||||
retry_send:
|
||||
res = sendmsg (fd, &msg_send, 0);
|
||||
if (res == -1 && errno == EINTR) {
|
||||
goto retry_send;
|
||||
}
|
||||
if (res == -1) {
|
||||
res = -errno;
|
||||
}
|
||||
return (res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
int client_fd;
|
||||
int res;
|
||||
|
||||
res = uic_connect (&client_fd);
|
||||
if (res != 0) {
|
||||
printf ("Couldn't connect to live replacement service\n");
|
||||
}
|
||||
uic_msg_send (client_fd, "livereplace ckpt version 2");
|
||||
|
||||
return 0;
|
||||
}
|
155
lcr/uis.c
Executable file
155
lcr/uis.c
Executable file
@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (C) 2006 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:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* 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
|
||||
* 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
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/uio.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <sched.h>
|
||||
#include <time.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/poll.h>
|
||||
|
||||
#define SERVER_BACKLOG 5
|
||||
|
||||
char *socketname = "lcr.socket";
|
||||
|
||||
static void uis_lcr_bind (int *server_fd)
|
||||
{
|
||||
int fd;
|
||||
struct sockaddr_un un_addr;
|
||||
int res;
|
||||
|
||||
/*
|
||||
* Create socket for lcr clients, name socket, listen for connections
|
||||
*/
|
||||
fd = socket (PF_UNIX, SOCK_STREAM, 0);
|
||||
if (fd == -1) {
|
||||
printf ("lcr_bind failed\n");
|
||||
};
|
||||
|
||||
memset (&un_addr, 0, sizeof (struct sockaddr_un));
|
||||
un_addr.sun_family = AF_UNIX;
|
||||
strcpy (un_addr.sun_path + 1, socketname);
|
||||
|
||||
res = bind (fd, (struct sockaddr *)&un_addr, sizeof (struct sockaddr_un));
|
||||
if (res) {
|
||||
printf ("Could not bind AF_UNIX: %s\n", strerror (errno));
|
||||
}
|
||||
listen (fd, SERVER_BACKLOG);
|
||||
*server_fd = fd;
|
||||
}
|
||||
|
||||
struct uis_commands {
|
||||
char *command;
|
||||
void (*cmd_handler) (char *);
|
||||
};
|
||||
|
||||
void cmd1 (char *cmd) {
|
||||
printf ("cmd1 executed with cmd line %s\n", cmd);
|
||||
}
|
||||
|
||||
struct uis_commands uis_commands[] = {
|
||||
{
|
||||
"cmd1", cmd1
|
||||
}
|
||||
};
|
||||
|
||||
struct req_msg {
|
||||
int len;
|
||||
char msg[0];
|
||||
};
|
||||
|
||||
static void lcr_uis_dispatch (int fd)
|
||||
{
|
||||
struct req_msg header;
|
||||
char msg_contents[512];
|
||||
|
||||
read (fd, &header, sizeof (header));
|
||||
read (fd, msg_contents, sizeof (msg_contents));
|
||||
|
||||
printf ("msg contents %s\n", msg_contents);
|
||||
}
|
||||
|
||||
static void *lcr_uis_server (void *data)
|
||||
{
|
||||
struct pollfd ufds[2];
|
||||
struct sockaddr_un un_addr;
|
||||
socklen_t addrlen;
|
||||
int nfds = 1;
|
||||
int on = 1;
|
||||
int res;
|
||||
|
||||
/*
|
||||
* Main acceptance and dispatch loop
|
||||
*/
|
||||
uis_lcr_bind (&ufds[0].fd);
|
||||
printf ("UIS server thread started %d\n", ufds[0].fd);
|
||||
ufds[0].events = POLLIN;
|
||||
ufds[1].events = POLLOUT;
|
||||
for (;;) {
|
||||
res = poll (ufds, nfds, -1);
|
||||
if (nfds == 1 && ufds[0].revents & POLLIN) {
|
||||
ufds[1].fd = accept (ufds[0].fd,
|
||||
(struct sockaddr *)&un_addr, &addrlen);
|
||||
setsockopt(ufds[1].fd, SOL_SOCKET, SO_PASSCRED,
|
||||
&on, sizeof (on));
|
||||
nfds = 2;
|
||||
}
|
||||
if (ufds[0].revents & POLLIN) {
|
||||
lcr_uis_dispatch (ufds[1].fd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lcr_uis_ctors (void)
|
||||
{
|
||||
pthread_t thread;
|
||||
|
||||
pthread_create (&thread, NULL, lcr_uis_server, NULL);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int (*const __init_uis[1]) (void) __attribute__ ((section(".ctors"))) =
|
||||
{ lcr_uis_ctors };
|
33
lib/Makefile
33
lib/Makefile
@ -44,8 +44,8 @@ LDFLAGS = -g
|
||||
#LDFLAGS = -g
|
||||
|
||||
all:libSaClm.a libSaClm.so.1.0 libSaAmf.a libSaAmf.so.1.0 libSaCkpt.a \
|
||||
libSaCkpt.so.1.0 libSaEvt.a libSaEvt.so.1.0 libSaLck.a libSaLck.so.1.0 \
|
||||
libais.a libais.so.1.0 libevs.a libevs.so.1.0 libOpenaisCfg.a libOpenaisCfg.so.1.0
|
||||
libSaCkpt.so.1.0 libSaEvt.a libSaEvt.so.1.0 libSaLck.a libSaLck.so.1.0 libSaMsg.a libSaMsg.so.1.0 \
|
||||
libais.a libais.so.1.0 libevs.a libevs.so.1.0
|
||||
|
||||
LIBAIS_SRC = util.c amf.c clm.c ckpt.c evt.c
|
||||
|
||||
@ -91,15 +91,24 @@ libSaLck.a: util.o lck.o
|
||||
$(AR) -rc libSaLck.a util.o lck.o
|
||||
|
||||
libSaLck.so.1.0: util.o lck.o
|
||||
$(CC) -shared -Wl,-soname,libSaLck.so.1,-version-script=libSaLck.versions util.o lck.o -o $@
|
||||
$(CC) -shared -Wl,-soname,libSaLCK.so.1,-version-script=libSaLck.versions util.o lck.o -o $@
|
||||
rm -f libSaLck.so.1 libSaLck.so
|
||||
ln -s libSaLck.so.1.0 libSaLck.so.1
|
||||
ln -s libSaLck.so.1.0 libSaLck.so
|
||||
|
||||
libais.a: util.o amf.o clm.o ckpt.o evt.o
|
||||
$(AR) -rc libais.a util.o amf.o clm.o ckpt.o evt.o
|
||||
libSaMsg.a: util.o msg.o
|
||||
$(AR) -rc libSaMsg.a util.o msg.o
|
||||
|
||||
libais.so.1.0: util.o amf.o clm.o ckpt.o evt.o lck.o
|
||||
libSaMsg.so.1.0: util.o msg.o
|
||||
$(CC) -shared -Wl,-soname,libSaMsg.so.1,-version-script=libSaMsg.versions util.o msg.o -o $@
|
||||
rm -f libSaMsg.so.1 libSaMsg.so
|
||||
ln -s libSaMsg.so.1.0 libSaMsg.so.1
|
||||
ln -s libSaMsg.so.1.0 libSaMsg.so
|
||||
|
||||
libais.a: util.o amf.o clm.o ckpt.o evt.o msg.o
|
||||
$(AR) -rc libais.a util.o amf.o clm.o ckpt.o evt.o msg.o
|
||||
|
||||
libais.so.1.0: util.o amf.o clm.o ckpt.o evt.o lck.o msg.o
|
||||
$(CC) -shared -Wl,-soname,libais.so.1,-version-script=libSaAis.versions util.o amf.o clm.o ckpt.o \
|
||||
evt.o -o $@
|
||||
rm -f libais.so.1 libais.so
|
||||
@ -115,18 +124,10 @@ libevs.so.1.0: util.o evs.o
|
||||
ln -s libevs.so.1.0 libevs.so.1
|
||||
ln -s libevs.so.1.0 libevs.so
|
||||
|
||||
libOpenaisCfg.a: util.o cfg.o
|
||||
$(AR) -rc libOpenaisCfg.a util.o cfg.o
|
||||
|
||||
libOpenaisCfg.so.1.0: util.o cfg.o
|
||||
$(CC) -shared -Wl,-soname,libOpenaisCfg.so.1,-version-script=libOpenaisCfg.versions util.o cfg.o -o $@
|
||||
rm -f libOpenaisCfg.so.1 libOpenaisCfg.so
|
||||
ln -s libOpenaisCfg.so.1.0 libOpenaisCfg.so.1
|
||||
ln -s libOpenaisCfg.so.1.0 libOpenaisCfg.so
|
||||
|
||||
clean:
|
||||
rm -f *.o libais.so* libais.a libSaClm.so* libSaClm.a* libSaAmf.so* libSaAmf.a \
|
||||
libSaCkpt.so* libSaCkpt.a* libSaEvt.so* libSaEvt.a libSaLck.so libSaLck.a \
|
||||
libSaCkpt.so* libSaCkpt.a* libSaEvt.so* libSaEvt.a libSaLck.so* libSaLck.a \
|
||||
libSaMsg.so* libSaMsg.a libOpenaisCfg.so* libOpenaisCfg.a \
|
||||
libevs.so* libevs.a *.da *.bb *.bbg
|
||||
|
||||
# -fPIC rules required for all libraries
|
||||
|
24
lib/libSaMsg.versions
Normal file
24
lib/libSaMsg.versions
Normal file
@ -0,0 +1,24 @@
|
||||
# Version and symbol export for libSaLck.so
|
||||
|
||||
OPENAIS_LCK_B.01.01 {
|
||||
global:
|
||||
saLckInitialize;
|
||||
saLckSelectionObjectGet;
|
||||
saLckDispatch;
|
||||
saLckinalize;
|
||||
local:
|
||||
saHandleCreate;
|
||||
saHandleDestroy;
|
||||
saHandleInstanceGet;
|
||||
saHandleInstancePut;
|
||||
saPollRetry;
|
||||
saRecvRetry;
|
||||
saSendMsgReceiveReply;
|
||||
saSendMsgRetry;
|
||||
saSendReceiveReply;
|
||||
saSendRetry;
|
||||
saServiceConnect;
|
||||
saServiceConnectTwo;
|
||||
saVersionVerify;
|
||||
clustTimeNow;
|
||||
};
|
@ -28,7 +28,7 @@
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
# THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
LIBRARIES= ../lib/libSaClm.a ../lib/libSaAmf.a ../lib/libSaCkpt.a ../lib/libSaEvt.a ../lib/libSaLck.a ../lib/libevs.a
|
||||
LIBRARIES= ../lib/libSaClm.a ../lib/libSaAmf.a ../lib/libSaCkpt.a ../lib/libSaEvt.a ../lib/libSaLck.a ../lib/libSaMsg.a ../lib/libevs.a
|
||||
LIBS = $(LIBRARIES) -lpthread
|
||||
|
||||
# Production mode flags
|
||||
@ -48,14 +48,17 @@ LDFLAGS = -g -L../lib
|
||||
#LDFLAGS = -pg -L../lib
|
||||
|
||||
EXTRA_CFLAGS = -I../include
|
||||
TEST_SRC = testclm.c testamf1.c testckpt.c ckptstress.c ckptbench.c \
|
||||
TEST_SRC = testclm.c testamf1.c \
|
||||
testamf4.c testamf5.c testamf6.c testamfth.c \
|
||||
testckpt.c ckptstress.c ckptbench.c \
|
||||
ckptbenchth.c testevt.c testevs.c evsbench.c \
|
||||
subscription.c publish.c evtbench.c \
|
||||
sa_error.c unlink.c testclm2.c testlck.c
|
||||
sa_error.c unlink.c testclm2.c testlck.c testmsg.c
|
||||
|
||||
all: testclm testamf1 testckpt ckptstress ckptbench \
|
||||
all: testclm testamf1 \
|
||||
testckpt ckptstress ckptbench \
|
||||
ckptbenchth ckpt-rd ckpt-wr testevt testevs \
|
||||
evsbench subscription publish evtbench unlink testclm2 testlck
|
||||
evsbench subscription publish evtbench unlink testclm2 testlck testmsg
|
||||
|
||||
testtimer: testtimer.o $(LIBRARIES)
|
||||
$(CC) $(LDFLAGS) -o testtimer testtimer.o ../exec/timer.o
|
||||
@ -81,18 +84,6 @@ testamf5: testamf5.o $(LIBRARIES)
|
||||
testamf6: testamf6.o $(LIBRARIES)
|
||||
$(CC) $(LDFLAGS) -o testamf6 testamf6.o $(LIBS)
|
||||
|
||||
testamf7: testamf7.o $(LIBRARIES)
|
||||
$(CC) $(LDFLAGS) -o testamf7 testamf7.o $(LIBS)
|
||||
|
||||
testamf8: testamf8.o $(LIBRARIES)
|
||||
$(CC) $(LDFLAGS) -o testamf8 testamf8.o $(LIBS)
|
||||
|
||||
testamf9: testamf9.o $(LIBRARIES)
|
||||
$(CC) $(LDFLAGS) -o testamf9 testamf9.o $(LIBS)
|
||||
|
||||
testamf10: testamf10.o $(LIBRARIES)
|
||||
$(CC) $(LDFLAGS) -o testamf10 testamf10.o $(LIBS)
|
||||
|
||||
testamfth: testamfth.o $(LIBRARIES)
|
||||
$(CC) $(LDFLAGS) -o testamfth testamfth.o $(LIBS)
|
||||
|
||||
@ -150,11 +141,14 @@ testclm2: testclm2.o $(LIBRARIES)
|
||||
testlck: testlck.o $(LIBRARIES)
|
||||
$(CC) $(LDFLAGS) -o testlck testlck.o $(LIBS)
|
||||
|
||||
testmsg: testmsg.o $(LIBRARIES)
|
||||
$(CC) $(LDFLAGS) -o testmsg testmsg.o $(LIBS)
|
||||
|
||||
clean:
|
||||
rm -f *.o testclm testamf testamf1 testamf2 testamf3 testamf4 \
|
||||
testamf5 testamf6 testamfth testckpt ckptstress testtimer \
|
||||
ckptbench ckptbenchth testevt testevs ckpt-wr ckpt-rd \
|
||||
evsbench subscription publish evtbench unlink
|
||||
evsbench subscription publish evtbench unlink testmsg
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
|
@ -173,7 +173,7 @@ int main (void) {
|
||||
result = evs_leave (handle, &groups[0], 1);
|
||||
printf ("Leave result %d\n", result);
|
||||
|
||||
size = 1;
|
||||
size = 100000;
|
||||
|
||||
for (i = 0; i < 225; i++) { /* number of repetitions - up to 50k */
|
||||
evs_benchmark (handle, size);
|
||||
|
178
test/testmsg.c
Normal file
178
test/testmsg.c
Normal file
@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright (c) 2005 MontaVista Software, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither the name of the MontaVista Software, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* 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
|
||||
* 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
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include "saAis.h"
|
||||
#include "saMsg.h"
|
||||
|
||||
void QueueOpenCallback (
|
||||
SaInvocationT invocation,
|
||||
SaMsgQueueHandleT queueHandle,
|
||||
SaAisErrorT error)
|
||||
{
|
||||
}
|
||||
|
||||
void QueueGroupTrackCallback (
|
||||
const SaNameT *queueGroupName,
|
||||
const SaMsgQueueGroupNotificationBufferT *notificationBuffer,
|
||||
SaUint32T numberOfMembers,
|
||||
SaAisErrorT error)
|
||||
{
|
||||
}
|
||||
|
||||
void MessageDeliveredCallback (
|
||||
SaInvocationT invocation,
|
||||
SaAisErrorT error)
|
||||
{
|
||||
}
|
||||
|
||||
void MessageReceivedCallback (
|
||||
SaMsgQueueHandleT queueHandle)
|
||||
{
|
||||
}
|
||||
|
||||
SaMsgCallbacksT callbacks = {
|
||||
.saMsgQueueOpenCallback = QueueOpenCallback,
|
||||
.saMsgQueueGroupTrackCallback = QueueGroupTrackCallback,
|
||||
.saMsgMessageDeliveredCallback = MessageDeliveredCallback,
|
||||
.saMsgMessageReceivedCallback = MessageReceivedCallback
|
||||
};
|
||||
|
||||
SaVersionT version = { 'B', 1, 1 };
|
||||
|
||||
SaMsgQueueCreationAttributesT creation_attributes = {
|
||||
SA_MSG_QUEUE_PERSISTENT,
|
||||
{128000, 128000, 128000},
|
||||
SA_TIME_END
|
||||
};
|
||||
|
||||
void setSaNameT (SaNameT *name, char *str) {
|
||||
name->length = strlen (str);
|
||||
memcpy (name->value, str, name->length);
|
||||
}
|
||||
|
||||
void sigintr_handler (int signum) {
|
||||
exit (0);
|
||||
}
|
||||
|
||||
int main (void) {
|
||||
SaMsgHandleT handle;
|
||||
SaMsgQueueHandleT queue_handle;
|
||||
fd_set read_fds;
|
||||
SaSelectionObjectT select_fd;
|
||||
int result;
|
||||
SaNameT queue_name;
|
||||
SaNameT queue_group_name;
|
||||
|
||||
signal (SIGINT, sigintr_handler);
|
||||
|
||||
result = saMsgInitialize (&handle, &callbacks, &version);
|
||||
if (result != SA_OK) {
|
||||
printf ("Could not initialize Cluster Membership API instance error %d\n", result);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
saMsgSelectionObjectGet (handle, &select_fd);
|
||||
|
||||
setSaNameT (&queue_name, "queue");
|
||||
|
||||
result = saMsgQueueOpen (handle,
|
||||
&queue_name,
|
||||
&creation_attributes,
|
||||
SA_MSG_QUEUE_CREATE,
|
||||
SA_TIME_END,
|
||||
&queue_handle);
|
||||
printf ("saMsgQueueOpen result is %d (should be 1)\n", result);
|
||||
|
||||
setSaNameT (&queue_group_name, "queue_group");
|
||||
|
||||
result = saMsgQueueGroupCreate (
|
||||
handle,
|
||||
&queue_group_name,
|
||||
SA_MSG_QUEUE_GROUP_ROUND_ROBIN);
|
||||
printf ("saMsgQueueGroupCreate result is %d (should be 1)\n", result);
|
||||
|
||||
result = saMsgQueueGroupCreate (
|
||||
handle,
|
||||
&queue_group_name,
|
||||
SA_MSG_QUEUE_GROUP_ROUND_ROBIN);
|
||||
printf ("saMsgQueueGroupCreate result is %d (should be 14)\n", result);
|
||||
|
||||
result = saMsgQueueGroupInsert (
|
||||
handle,
|
||||
&queue_group_name,
|
||||
&queue_name);
|
||||
printf ("saMsgQueueGroupInsert result is %d (should be 1)\n", result);
|
||||
|
||||
|
||||
FD_ZERO (&read_fds);
|
||||
do {
|
||||
FD_SET (select_fd, &read_fds);
|
||||
FD_SET (STDIN_FILENO, &read_fds);
|
||||
result = select (select_fd + 1, &read_fds, 0, 0, 0);
|
||||
if (result == -1) {
|
||||
perror ("select\n");
|
||||
}
|
||||
if (FD_ISSET (STDIN_FILENO, &read_fds)) {
|
||||
break;
|
||||
}
|
||||
saMsgDispatch (handle, SA_DISPATCH_ALL);
|
||||
} while (result);
|
||||
|
||||
result = saMsgQueueGroupRemove (
|
||||
handle,
|
||||
&queue_group_name,
|
||||
&queue_name);
|
||||
printf ("saMsgQueueGroupRemove result is %d (should be 1)\n", result);
|
||||
|
||||
result = saMsgQueueGroupDelete (handle,
|
||||
&queue_group_name);
|
||||
printf ("saMsgQueueGroupDelete result is %d (should be 1)\n", result);
|
||||
|
||||
result = saMsgQueueClose (queue_handle);
|
||||
printf ("saMsgQueueClose result is %d (should be 1)\n", result);
|
||||
|
||||
result = saMsgFinalize (handle);
|
||||
printf ("Finalize result is %d (should be 1)\n", result);
|
||||
return (0);
|
||||
}
|
Loading…
Reference in New Issue
Block a user