Reviewed-by: Steven Dake <sdake@xxxxxxxxxx> On 12/14/2011 08:41 AM, Jan Friesse wrote: > Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx> > --- > configure.ac | 2 +- > corosync.spec.in | 13 +- > cts/agents/Makefile.am | 10 +- > cts/agents/cmap-dispatch-deadlock.sh | 57 + > cts/agents/confdb-dispatch-deadlock.sh | 57 - > cts/agents/confdb_test_agent.c | 643 ----------- > cts/corosync.py | 15 - > cts/corotests.py | 88 +-- > exec/Makefile.am | 7 +- > exec/objdb.c | 1857 -------------------------------- > include/Makefile.am | 6 +- > include/corosync/confdb.h | 353 ------ > include/corosync/corotypes.h | 17 - > include/corosync/engine/coroapi.h | 244 ----- > include/corosync/engine/objdb.h | 275 ----- > include/corosync/ipc_confdb.h | 278 ----- > include/corosync/totem/totem.h | 1 - > lib/Makefile.am | 13 +- > lib/confdb.c | 1814 ------------------------------- > lib/libconfdb.versions | 24 - > lib/libconfdb.verso | 1 - > lib/sa-confdb.c | 449 -------- > lib/sa-confdb.h | 112 -- > pkgconfig/Makefile.am | 4 +- > services/Makefile.am | 2 +- > services/confdb.c | 1094 ------------------- > test/.gitignore | 1 - > test/Makefile.am | 4 +- > test/testconfdb.c | 259 ----- > tools/Makefile.am | 6 +- > tools/corosync-objctl.c | 935 ---------------- > 31 files changed, 87 insertions(+), 8554 deletions(-) > create mode 100644 cts/agents/cmap-dispatch-deadlock.sh > delete mode 100644 cts/agents/confdb-dispatch-deadlock.sh > delete mode 100644 cts/agents/confdb_test_agent.c > delete mode 100644 exec/objdb.c > delete mode 100644 include/corosync/confdb.h > delete mode 100644 include/corosync/engine/objdb.h > delete mode 100644 include/corosync/ipc_confdb.h > delete mode 100644 lib/confdb.c > delete mode 100644 lib/libconfdb.versions > delete mode 100644 lib/libconfdb.verso > delete mode 100644 lib/sa-confdb.c > delete mode 100644 lib/sa-confdb.h > delete mode 100644 services/confdb.c > delete mode 100644 test/testconfdb.c > delete mode 100644 tools/corosync-objctl.c > > diff --git a/configure.ac b/configure.ac > index 3a47471..50a1dc9 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -215,13 +215,13 @@ SONAME="${SOMAJOR}.${SOMINOR}.${SOMICRO}" > > # specific libraries SONAME > LIB_SONAME_IMPORT([cfg]) > -LIB_SONAME_IMPORT([confdb]) > LIB_SONAME_IMPORT([cpg]) > LIB_SONAME_IMPORT([evs]) > LIB_SONAME_IMPORT([pload]) > LIB_SONAME_IMPORT([quorum]) > LIB_SONAME_IMPORT([sam]) > LIB_SONAME_IMPORT([votequorum]) > +LIB_SONAME_IMPORT([cmap]) > > # local options > AC_ARG_ENABLE([ansi], > diff --git a/corosync.spec.in b/corosync.spec.in > index 8446802..e204348 100644 > --- a/corosync.spec.in > +++ b/corosync.spec.in > @@ -169,11 +169,10 @@ fi > %endif > %dir %{_libexecdir}/lcrso > %{_libexecdir}/lcrso/coroparse.lcrso > -%{_libexecdir}/lcrso/objdb.lcrso > %{_libexecdir}/lcrso/service_cfg.lcrso > %{_libexecdir}/lcrso/service_cpg.lcrso > %{_libexecdir}/lcrso/service_evs.lcrso > -%{_libexecdir}/lcrso/service_confdb.lcrso > +%{_libexecdir}/lcrso/service_cmap.lcrso > %{_libexecdir}/lcrso/service_pload.lcrso > %{_libexecdir}/lcrso/quorum_votequorum.lcrso > %{_libexecdir}/lcrso/quorum_testquorum.lcrso > @@ -218,7 +217,6 @@ This package contains corosync test agents. > %{_datadir}/corosync/tests/mem_leak_test.sh > %{_datadir}/corosync/tests/net_breaker.sh > %{_bindir}/cpg_test_agent > -%{_bindir}/confdb_test_agent > %{_bindir}/sam_test_agent > %{_bindir}/votequorum_test_agent > %{_libexecdir}/lcrso/service_syncv2.lcrso > @@ -240,10 +238,11 @@ This package contains corosync libraries. > %doc LICENSE > %{_libdir}/libcfg.so.* > %{_libdir}/libcpg.so.* > -%{_libdir}/libconfdb.so.* > +%{_libdir}/libcmap.so.* > %{_libdir}/libevs.so.* > %{_libdir}/libtotem_pg.so.* > %{_libdir}/liblogsys.so.* > +%{_libdir}/libicmap.so.* > %{_libdir}/libquorum.so.* > %{_libdir}/libvotequorum.so.* > %{_libdir}/libpload.so.* > @@ -272,7 +271,7 @@ The Corosync Cluster Engine APIs. > %{_includedir}/corosync/cs_config.h > %{_includedir}/corosync/corodefs.h > %{_includedir}/corosync/cfg.h > -%{_includedir}/corosync/confdb.h > +%{_includedir}/corosync/cmap.h > %{_includedir}/corosync/corotypes.h > %{_includedir}/corosync/cpg.h > %{_includedir}/corosync/evs.h > @@ -295,11 +294,11 @@ The Corosync Cluster Engine APIs. > %{_includedir}/corosync/engine/config.h > %{_includedir}/corosync/engine/coroapi.h > %{_includedir}/corosync/engine/logsys.h > -%{_includedir}/corosync/engine/objdb.h > +%{_includedir}/corosync/engine/icmap.h > %{_includedir}/corosync/engine/quorum.h > %{_libdir}/libcfg.so > %{_libdir}/libcpg.so > -%{_libdir}/libconfdb.so > +%{_libdir}/libcmap.so > %{_libdir}/libevs.so > %{_libdir}/libtotem_pg.so > %{_libdir}/liblogsys.so > diff --git a/cts/agents/Makefile.am b/cts/agents/Makefile.am > index 9c25377..0cdc48e 100644 > --- a/cts/agents/Makefile.am > +++ b/cts/agents/Makefile.am > @@ -34,14 +34,14 @@ INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ > -I$(top_builddir)/include/corosync > > SOURCES = > -TEST_AGENTS = cpg_test_agent confdb_test_agent sam_test_agent votequorum_test_agent > +TEST_AGENTS = cpg_test_agent sam_test_agent votequorum_test_agent > > EXTRA_DIST = syncv2.c > > if INSTALL_TESTAGENTS > agentdir = $(datadir)/$(PACKAGE)/tests > bin_PROGRAMS = $(TEST_AGENTS) > -dist_agent_SCRIPTS = mem_leak_test.sh net_breaker.sh confdb-dispatch-deadlock.sh shm_leak_audit.sh > +dist_agent_SCRIPTS = mem_leak_test.sh net_breaker.sh cmap-dispatch-deadlock.sh shm_leak_audit.sh > > AM_CFLAGS = -fPIC > SERVICE_LCRSO = syncv2 > @@ -50,7 +50,7 @@ LCRSO = $(SERVICE_LCRSO:%=service_%.lcrso) > LCRSO_OBJS = $(SOURCES:%.c=%.o) > else > noinst_PROGRAMS = $(TEST_AGENTS) > -noinst_SCRIPTS = mem_leak_test.sh net_breaker.sh confdb-dispatch-deadlock.sh shm_leak_audit.sh > +noinst_SCRIPTS = mem_leak_test.sh net_breaker.sh cmap-dispatch-deadlock.sh shm_leak_audit.sh > LCRSO = > LCRSO_OBJS = > endif > @@ -61,10 +61,6 @@ cpg_test_agent_SOURCES = cpg_test_agent.c common_test_agent.c > cpg_test_agent_LDADD = -lcpg -lcfg ../../exec/crypto.o $(LIBQB_LIBS) > cpg_test_agent_LDFLAGS = -L../../lib -L. > > -confdb_test_agent_SOURCES = confdb_test_agent.c common_test_agent.c > -confdb_test_agent_LDADD = -lconfdb $(LIBQB_LIBS) > -confdb_test_agent_LDFLAGS = -L../../lib > - > sam_test_agent_SOURCES = sam_test_agent.c common_test_agent.c > sam_test_agent_LDADD = -lsam -lquorum -lcmap $(LIBQB_LIBS) > sam_test_agent_LDFLAGS = -L../../lib > diff --git a/cts/agents/cmap-dispatch-deadlock.sh b/cts/agents/cmap-dispatch-deadlock.sh > new file mode 100644 > index 0000000..1ccc5bd > --- /dev/null > +++ b/cts/agents/cmap-dispatch-deadlock.sh > @@ -0,0 +1,57 @@ > +#!/bin/bash > + > +export TIMEOUT=600 > +export PID=$$ > +up_to=200 > + > +rec_plist() { > + if [ "$2" == "" ];then > + pl="`ps ax -o pid= -o ppid= -o comm=`" > + else > + pl=$2 > + fi > + > + list=`echo "$pl" | egrep "^ *[0-9]+ +$1" | awk '{ print $1 }'` > + tmplist=$list > + for i in $tmplist;do > + [ "$i" != "$1" ] && [ "$i" != "$$" ] && list="$list "`rec_plist $i "$pl"` > + done > + > + echo $list > +} > + > +rec_pkill() { > + kill -9 `rec_plist "$1"` 2> /dev/null > +} > + > +exit_timeout() { > + echo "ERR: Timeout. Test failed $PID" > + rec_pkill "$$" > + exit 1 > +} > + > +corosync-cmapctl -s test.abd "str" "test" || exit 2 > + > +trap exit_timeout SIGUSR1 > +(sleep $TIMEOUT ; kill -SIGUSR1 $PID) & > + > +wait_list="" > + > +for e in {1..40};do > + (for a in `seq 1 $up_to`;do corosync-cmapctl -s test.abd "str" $a ; done) & > + wait_list="$wait_list $!" > +done > + > +notify_list="" > + > +for i in {1..2};do > + sleep 600000 | corosync-cmapctl -t test > /dev/null & > + notify_list="$notify_list $!" > +done > + > +wait $wait_list > + > +rec_pkill "$$" > + > +echo "OK" > +exit 0 > diff --git a/cts/agents/confdb-dispatch-deadlock.sh b/cts/agents/confdb-dispatch-deadlock.sh > deleted file mode 100644 > index 4ba0c2d..0000000 > --- a/cts/agents/confdb-dispatch-deadlock.sh > +++ /dev/null > @@ -1,57 +0,0 @@ > -#!/bin/bash > - > -export TIMEOUT=600 > -export PID=$$ > -up_to=200 > - > -rec_plist() { > - if [ "$2" == "" ];then > - pl="`ps ax -o pid= -o ppid= -o comm=`" > - else > - pl=$2 > - fi > - > - list=`echo "$pl" | egrep "^ *[0-9]+ +$1" | awk '{ print $1 }'` > - tmplist=$list > - for i in $tmplist;do > - [ "$i" != "$1" ] && [ "$i" != "$$" ] && list="$list "`rec_plist $i "$pl"` > - done > - > - echo $list > -} > - > -rec_pkill() { > - kill -9 `rec_plist "$1"` 2> /dev/null > -} > - > -exit_timeout() { > - echo "ERR: Timeout. Test failed $PID" > - rec_pkill "$$" > - exit 1 > -} > - > -corosync-objctl -c test.abd || exit 2 > - > -trap exit_timeout SIGUSR1 > -(sleep $TIMEOUT ; kill -SIGUSR1 $PID) & > - > -wait_list="" > - > -for e in {1..40};do > - (for a in `seq 1 $up_to`;do corosync-objctl -w test.abd=$a ; done) & > - wait_list="$wait_list $!" > -done > - > -notify_list="" > - > -for i in {1..2};do > - sleep 600000 | corosync-objctl -t test > /dev/null & > - notify_list="$notify_list $!" > -done > - > -wait $wait_list > - > -rec_pkill "$$" > - > -echo "OK" > -exit 0 > diff --git a/cts/agents/confdb_test_agent.c b/cts/agents/confdb_test_agent.c > deleted file mode 100644 > index 97a3407..0000000 > --- a/cts/agents/confdb_test_agent.c > +++ /dev/null > @@ -1,643 +0,0 @@ > -/* > - * Copyright (c) 2008, 2009 Red Hat Inc > - * > - * All rights reserved. > - * > - * Author: Christine Caulfield <ccaulfie@xxxxxxxxxx> > - * > - * 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 <config.h> > - > -#include <stdio.h> > -#include <stdlib.h> > -#include <assert.h> > -#include <errno.h> > -#include <unistd.h> > -#include <string.h> > -#include <sys/types.h> > -#include <sys/socket.h> > -#include <netinet/in.h> > -#include <arpa/inet.h> > -#include <netdb.h> > -#include <sys/un.h> > -#include <syslog.h> > - > -#include <corosync/corotypes.h> > -#include <corosync/confdb.h> > -#include "common_test_agent.h" > - > -#define INCDEC_VALUE 45 > - > -confdb_callbacks_t callbacks = { > - .confdb_key_change_notify_fn = NULL, > - .confdb_object_create_change_notify_fn = NULL, > - .confdb_object_delete_change_notify_fn = NULL > -}; > - > -typedef enum { > - NTF_OBJECT_CREATED, > - NTF_OBJECT_DELETED, > - NTF_KEY_CREATED, > - NTF_KEY_REPLACED, > - NTF_KEY_DELETED, > - NTF_NONE, > -} ntf_callback_type_t; > - > -static ntf_callback_type_t callback_type; > -static char ntf_object_name[256]; > -static size_t ntf_object_name_len; > -static char ntf_key_name[256]; > -static size_t ntf_key_name_len; > -static char ntf_key_value[256]; > -static size_t ntf_key_value_len; > - > -static void ta_key_change_notify ( > - confdb_handle_t handle, > - confdb_change_type_t change_type, > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *object_name, > - size_t object_name_len, > - const void *key_name, > - size_t key_name_len, > - const void *key_value, > - size_t key_value_len) > -{ > - switch (change_type) { > - case OBJECT_KEY_CREATED: > - callback_type = NTF_KEY_CREATED; > - break; > - case OBJECT_KEY_DELETED: > - callback_type = NTF_KEY_DELETED; > - break; > - case OBJECT_KEY_REPLACED: > - callback_type = NTF_KEY_REPLACED; > - break; > - default: > - assert (0); > - break; > - } > - ntf_object_name_len = object_name_len; > - memcpy (ntf_object_name, object_name, object_name_len); > - > - ntf_key_name_len = key_name_len; > - memcpy (ntf_key_name, key_name, key_name_len); > - > - ntf_key_value_len = key_value_len; > - memcpy (ntf_key_value, key_value, key_value_len); > -} > - > -static void ta_object_create_notify ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *name_pt, > - size_t name_len) > -{ > - callback_type = NTF_OBJECT_CREATED; > - ntf_object_name_len = name_len; > - memcpy (ntf_object_name, name_pt, name_len); > -} > - > -static void ta_object_delete_notify ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *name_pt, > - size_t name_len) > -{ > - callback_type = NTF_OBJECT_DELETED; > - ntf_object_name_len = name_len; > - memcpy (ntf_object_name, name_pt, name_len); > -} > - > -confdb_callbacks_t valid_callbacks = { > - .confdb_key_change_notify_fn = ta_key_change_notify, > - .confdb_object_create_change_notify_fn = ta_object_create_notify, > - .confdb_object_delete_change_notify_fn = ta_object_delete_notify > -}; > - > -static void set_get_test (int sock) > -{ > - confdb_handle_t handle; > - char response[100]; > - int res; > - hdb_handle_t object_handle; > - confdb_value_types_t type; > - char key_value[256]; > - char key2_value[256]; > - size_t value_len; > - size_t value2_len; > - > - syslog (LOG_ERR, "%s START", __func__); > - > - snprintf (response, 100, "%s", OK_STR); > - > - res = confdb_initialize (&handle, &callbacks); > - if (res != CS_OK) { > - syslog (LOG_ERR, "Could not initialize confdb error %d", res); > - goto send_response; > - } > - /* Add a scratch object and put 2 keys into it */ > - res = confdb_object_create (handle, OBJECT_PARENT_HANDLE, > - "testconfdb", strlen("testconfdb"), &object_handle); > - if (res != CS_OK) { > - syslog (LOG_ERR, "error creating 'testconfdb' object: %d", res); > - goto send_response; > - } > - > - res = confdb_key_create (handle, object_handle, > - "testkey", strlen ("testkey"), > - "one", strlen ("one")); > - if (res != CS_OK) { > - syslog (LOG_ERR, "error creating 'testconfdb' key 1: %d", res); > - goto send_response; > - } > - > - res = confdb_key_replace (handle, object_handle, > - "testkey", strlen ("testkey"), > - "one", strlen ("one"), > - "newone", strlen ("newone")); > - if (res != CS_OK) { > - syslog (LOG_ERR, "error replace 'testconfdb' key 2: %d", res); > - goto send_response; > - } > - > - res = confdb_key_get_typed (handle, object_handle, > - "testkey", key_value, &value_len, &type); > - if (res != CS_OK) { > - syslog (LOG_ERR, "Could not get \"testkey\" key: %d", res); > - goto send_response; > - } > - if (strcmp (key_value, "newone") != 0) { > - syslog (LOG_ERR, "Key not set correctly"); > - goto send_response; > - } > - if (type != CONFDB_VALUETYPE_ANY) { > - syslog (LOG_ERR, "Key type not set correctly"); > - goto send_response; > - } > - res = confdb_key_get (handle, object_handle, > - "testkey", strlen ("testkey"), key2_value, &value2_len); > - if (res != CS_OK) { > - syslog (LOG_ERR, "Could not get \"testkey\" key: %d", res); > - goto send_response; > - } > - if (value2_len != value_len) { > - syslog (LOG_ERR, "value length from confdb_key_get:%u and confdb_key_get_typed:%u differ.", > - (uint32_t)value_len, (uint32_t)value2_len); > - goto send_response; > - } > - > - res = confdb_key_delete (handle, object_handle, > - "testkey", strlen ("testkey"), key2_value, value2_len); > - if (res != CS_OK) { > - syslog (LOG_ERR, "Could not get \"testkey\" key: %d", res); > - goto send_response; > - } > - > - /* Remove it. > - Check that it doesn't exist when the full tree dump runs next */ > - res = confdb_object_destroy(handle, object_handle); > - if (res != CS_OK) { > - syslog (LOG_ERR, "error destroying 'testconfdb' object: %d", res); > - goto send_response; > - } > - > - snprintf (response, 100, "%s", OK_STR); > - > -send_response: > - syslog (LOG_ERR, "%s %s", __func__, response); > - send (sock, response, strlen (response) + 1, 0); > - confdb_finalize (handle); > -} > - > -static void increment_decrement_test (int sock) > -{ > - char response[100]; > - int res; > - uint32_t incdec_value; > - hdb_handle_t object_handle; > - confdb_handle_t handle; > - confdb_handle_t par_handle; > - > - snprintf (response, 100, "%s", FAIL_STR); > - > - res = confdb_initialize (&handle, &callbacks); > - if (res != CS_OK) { > - syslog (LOG_ERR, "Could not initialize confdb error %d", res); > - goto send_response; > - } > - /* Add a scratch object and put 1 keys into it */ > - res = confdb_object_create(handle, OBJECT_PARENT_HANDLE, > - "testconfdb", strlen("testconfdb"), &object_handle); > - if (res != CS_OK) { > - syslog (LOG_ERR, "error creating 'testconfdb' object: %d", res); > - goto send_response; > - } > - > - res = confdb_object_parent_get (handle, object_handle, &par_handle); > - if (res != CS_OK) { > - syslog (LOG_ERR, "error getting parent of 'testconfdb' object: %d", res); > - goto send_response; > - } > - if (par_handle != OBJECT_PARENT_HANDLE) { > - syslog (LOG_ERR, "wrong parent handle"); > - goto send_response; > - } > - > - > - incdec_value = INCDEC_VALUE; > - res = confdb_key_create_typed (handle, object_handle, "incdec", > - &incdec_value, sizeof(incdec_value), CONFDB_VALUETYPE_UINT32); > - if (res != CS_OK) { > - syslog (LOG_ERR, "error creating 'testconfdb' key 4: %d\n", res); > - goto send_response; > - } > - res = confdb_key_increment(handle, object_handle, "incdec", strlen("incdec"), &incdec_value); > - if (res != CS_OK) { > - syslog (LOG_ERR, "error incrementing 'testconfdb' key 4: %d\n", res); > - goto send_response; > - } > - if (incdec_value == INCDEC_VALUE + 1) { > - syslog (LOG_INFO, "incremented value = %d\n", incdec_value); > - } > - else { > - syslog (LOG_ERR, "ERROR: incremented value = %d (should be %d)\n", incdec_value, INCDEC_VALUE+1); > - goto send_response; > - } > - res = confdb_key_decrement(handle, object_handle, "incdec", strlen("incdec"), &incdec_value); > - if (res != CS_OK) { > - syslog (LOG_ERR, "error decrementing 'testconfdb' key 4: %d\n", res); > - goto send_response; > - } > - if (incdec_value == INCDEC_VALUE) { > - syslog (LOG_ERR, "decremented value = %d\n", incdec_value); > - } > - else { > - syslog (LOG_ERR, "ERROR: decremented value = %d (should be %d)\n", incdec_value, INCDEC_VALUE); > - goto send_response; > - } > - /* Remove it. > - Check that it doesn't exist when the full tree dump runs next */ > - res = confdb_object_destroy(handle, object_handle); > - if (res != CS_OK) { > - syslog (LOG_ERR, "error destroying 'testconfdb' object: %d\n", res); > - goto send_response; > - } > - > - snprintf (response, 100, "%s", OK_STR); > - > -send_response: > - confdb_finalize (handle); > - send (sock, response, strlen (response) + 1, 0); > -} > - > - > -static void object_find_test (int sock) > -{ > - char response[100]; > - confdb_handle_t handle; > - int result; > - hdb_handle_t totem_handle; > - char key_value[256]; > - size_t value_len; > - > - snprintf (response, 100, "%s", FAIL_STR); > - > - result = confdb_initialize (&handle, &callbacks); > - if (result != CS_OK) { > - syslog (LOG_ERR, "Could not initialize confdb error %d\n", result); > - goto send_response; > - } > - > - /* Find "totem" and dump bits of it again, to test the direct APIs */ > - result = confdb_object_find_start(handle, OBJECT_PARENT_HANDLE); > - if (result != CS_OK) { > - syslog (LOG_ERR, "Could not start object_find %d\n", result); > - goto send_response; > - } > - > - result = confdb_object_find(handle, OBJECT_PARENT_HANDLE, "totem", strlen("totem"), &totem_handle); > - if (result != CS_OK) { > - syslog (LOG_ERR, "Could not object_find \"totem\": %d\n", result); > - goto send_response; > - } > - > - result = confdb_key_get(handle, totem_handle, "version", strlen("version"), key_value, &value_len); > - if (result != CS_OK) { > - syslog (LOG_ERR, "Could not get \"version\" key: %d\n", result); > - goto send_response; > - } > - > - result = confdb_object_find_destroy (handle, OBJECT_PARENT_HANDLE); > - if (result != CS_OK) { > - syslog (LOG_ERR, "Could not destroy find object %d\n", result); > - goto send_response; > - } > - > - > - snprintf (response, 100, "%s", OK_STR); > - > -send_response: > - confdb_finalize (handle); > - send (sock, response, strlen (response) + 1, 0); > -} > - > -static void notification_test (int sock) > -{ > - char response[100]; > - confdb_handle_t handle; > - int res; > - hdb_handle_t object_handle; > - hdb_handle_t new_object_handle; > - uint16_t incdec_value; > - uint16_t incdec_value_new; > - uint32_t incdec_value_out; > - > - snprintf (response, 100, "%s", FAIL_STR); > - > - res = confdb_initialize (&handle, &valid_callbacks); > - if (res != CS_OK) { > - syslog (LOG_ERR, "Could not initialize confdb error %d\n", res); > - goto send_response; > - } > - > - /* Add a base scratch object (we don't want to track the parent object) */ > - res = confdb_object_create(handle, OBJECT_PARENT_HANDLE, > - "testconfdb", strlen("testconfdb"), &object_handle); > - if (res != CS_OK) { > - syslog (LOG_ERR, "error creating 'testconfdb' object: %d", res); > - goto send_response; > - } > - > - res = confdb_track_changes (handle, object_handle, 1 /*OBJECT_TRACK_DEPTH_RECURSIVE*/); > - if (res != CS_OK) { > - syslog (LOG_ERR, "can't track changes on object: %d", res); > - goto send_response; > - } > - > - /* Test 'object created' notification > - */ > - callback_type = NTF_NONE; > - > - res = confdb_object_create(handle, object_handle, > - "duck", strlen("duck"), &new_object_handle); > - if (res != CS_OK) { > - syslog (LOG_ERR, "error creating 'duck' object: %d", res); > - goto send_response; > - } > - > - confdb_dispatch (handle, CS_DISPATCH_ALL); > - > - if (callback_type != NTF_OBJECT_CREATED) { > - syslog (LOG_ERR, "no notification received for the creation of 'duck'"); > - goto send_response; > - } > - if (strcmp ("duck", ntf_object_name) != 0) { > - syslog (LOG_ERR, "expected notification for 'duck' but got %s", ntf_object_name); > - goto send_response; > - } > - > - /* Test 'key created' notification > - */ > - callback_type = NTF_NONE; > - > - incdec_value = INCDEC_VALUE; > - res = confdb_key_create_typed (handle, new_object_handle, "incdec", > - &incdec_value, sizeof(incdec_value), CONFDB_VALUETYPE_UINT16); > - if (res != CS_OK) { > - syslog (LOG_ERR, "error creating 'testconfdb' key 4: %d\n", res); > - goto send_response; > - } > - > - confdb_dispatch (handle, CS_DISPATCH_ALL); > - > - if (callback_type != NTF_KEY_CREATED) { > - syslog (LOG_ERR, "no notification received for the creation of key 'incdec'"); > - goto send_response; > - } > - if (strcmp ("incdec", ntf_key_name) != 0) { > - syslog (LOG_ERR, "expected notification for 'incdec' but got %s", ntf_key_name); > - goto send_response; > - } > - > - /* Test 'key replaced' notification for key_replace() > - */ > - callback_type = NTF_NONE; > - incdec_value_new = 413; > - res = confdb_key_replace(handle, new_object_handle, "incdec", strlen("incdec"), > - &incdec_value, sizeof(incdec_value), > - &incdec_value_new, sizeof(incdec_value_new)); > - if (res != CS_OK) { > - syslog (LOG_ERR, "error replacing 'incdec' key: %d\n", res); > - goto send_response; > - } > - > - confdb_dispatch (handle, CS_DISPATCH_ALL); > - > - if (callback_type != NTF_KEY_REPLACED) { > - syslog (LOG_ERR, "no notification received for the incrementing of key 'incdec'"); > - goto send_response; > - } > - if (strcmp ("incdec", ntf_key_name) != 0) { > - syslog (LOG_ERR, "expected notification for 'incdec' but got %s", ntf_key_name); > - goto send_response; > - } > - /* Test NO 'key replaced' notification for key_replace() of the same > - * value. > - */ > - callback_type = NTF_NONE; > - incdec_value = incdec_value_new; > - res = confdb_key_replace(handle, new_object_handle, "incdec", strlen("incdec"), > - &incdec_value_new, sizeof(incdec_value), > - &incdec_value, sizeof(incdec_value_new)); > - if (res != CS_OK) { > - syslog (LOG_ERR, "error replacing 'incdec' key: %d\n", res); > - goto send_response; > - } > - > - confdb_dispatch (handle, CS_DISPATCH_ALL); > - > - if (callback_type != NTF_NONE) { > - syslog (LOG_ERR, "notification received for the replacing the same value of key 'incdec'"); > - goto send_response; > - } > - if (strcmp ("incdec", ntf_key_name) != 0) { > - syslog (LOG_ERR, "expected notification for 'incdec' but got %s", ntf_key_name); > - goto send_response; > - } > - > - > - /* Test 'key replaced' notification for key_increment() > - */ > - callback_type = NTF_NONE; > - > - res = confdb_key_increment(handle, new_object_handle, "incdec", strlen("incdec"), &incdec_value_out); > - if (res != CS_OK) { > - syslog (LOG_ERR, "error incrementing 'testconfdb' key 4: %d\n", res); > - goto send_response; > - } > - > - confdb_dispatch (handle, CS_DISPATCH_ALL); > - > - if (callback_type != NTF_KEY_REPLACED) { > - syslog (LOG_ERR, "no notification received for the incrementing of key 'incdec'"); > - goto send_response; > - } > - if (strcmp ("incdec", ntf_key_name) != 0) { > - syslog (LOG_ERR, "expected notification for 'incdec' but got %s", ntf_key_name); > - goto send_response; > - } > - > - /* Test 'key destroyed' notification > - */ > - callback_type = NTF_NONE; > - > - res = confdb_key_delete (handle, new_object_handle, > - "incdec", strlen ("incdec"), ntf_key_value, ntf_key_value_len); > - if (res != CS_OK) { > - syslog (LOG_ERR, "Could not delete \"incdec\" key: %d", res); > - goto send_response; > - } > - > - confdb_dispatch (handle, CS_DISPATCH_ALL); > - > - if (callback_type != NTF_KEY_DELETED) { > - syslog (LOG_ERR, "no notification received for the deletion of key 'incdec'"); > - goto send_response; > - } > - if (strcmp ("incdec", ntf_key_name) != 0) { > - syslog (LOG_ERR, "expected notification for 'incdec' but got %s", ntf_key_name); > - goto send_response; > - } > - > - /* Test 'object destroyed' notification > - */ > - callback_type = NTF_NONE; > - > - res = confdb_object_destroy(handle, new_object_handle); > - if (res != CS_OK) { > - syslog (LOG_ERR, "error destroying 'testconfdb' object: %d", res); > - goto send_response; > - } > - > - confdb_dispatch (handle, CS_DISPATCH_ALL); > - > - if (callback_type != NTF_OBJECT_DELETED) { > - syslog (LOG_ERR, "no notification received for the deletion of 'duck'"); > - goto send_response; > - } > - if (strcmp ("duck", ntf_object_name) != 0) { > - syslog (LOG_ERR, "expected notification for 'duck' but got %s", ntf_object_name); > - goto send_response; > - } > - confdb_stop_track_changes (handle); > - confdb_object_destroy(handle, object_handle); > - > - snprintf (response, 100, "%s", OK_STR); > - > -send_response: > - send (sock, response, strlen (response) + 1, 0); > - confdb_finalize (handle); > -} > - > - > -static void context_test (int sock) > -{ > - confdb_handle_t handle; > - char response[100]; > - char *cmp; > - int res; > - > - snprintf (response, 100, "%s", OK_STR); > - > - res = confdb_initialize (&handle, &valid_callbacks); > - if (res != CS_OK) { > - syslog (LOG_ERR, "Could not initialize confdb error %d\n", res); > - goto send_response; > - } > - > - confdb_context_set (handle, response); > - confdb_context_get (handle, (const void**)&cmp); > - if (response != cmp) { > - snprintf (response, 100, "%s", FAIL_STR); > - } > - > -send_response: > - send (sock, response, strlen (response) + 1, 0); > - confdb_finalize (handle); > -} > - > -static void do_command (int sock, char* func, char*args[], int num_args) > -{ > - char response[100]; > - > - if (parse_debug) > - syslog (LOG_DEBUG,"RPC:%s() called.", func); > - > - if (strcmp ("set_get_test", func) == 0) { > - set_get_test (sock); > - } else if (strcmp ("increment_decrement_test", func) == 0) { > - increment_decrement_test (sock); > - } else if (strcmp ("object_find_test", func) == 0) { > - object_find_test (sock); > - } else if (strcmp ("notification_test", func) == 0) { > - notification_test (sock); > - } else if (strcmp ("context_test", func) == 0) { > - context_test (sock); > - } else if (strcmp ("are_you_ok_dude", func) == 0) { > - snprintf (response, 100, "%s", OK_STR); > - send (sock, response, strlen (response) + 1, 0); > - } else { > - syslog (LOG_ERR,"%s RPC:%s not supported!", __func__, func); > - snprintf (response, 100, "%s", NOT_SUPPORTED_STR); > - send (sock, response, strlen (response) + 1, 0); > - } > -} > - > -static void my_pre_exit(void) > -{ > - syslog (LOG_INFO, "%s PRE EXIT", __FILE__); > -} > - > -int main (int argc, char *argv[]) > -{ > - int ret; > - > - openlog (NULL, LOG_CONS|LOG_PID, LOG_DAEMON); > - syslog (LOG_ERR, "%s STARTING", __FILE__); > - > - parse_debug = 1; > - ret = test_agent_run (9035, do_command, my_pre_exit); > - syslog (LOG_ERR, "%s EXITING", __FILE__); > - > - return ret; > -} > - > - > diff --git a/cts/corosync.py b/cts/corosync.py > index 8f42a1d..003c34e 100644 > --- a/cts/corosync.py > +++ b/cts/corosync.py > @@ -140,7 +140,6 @@ class corosync_needle(ClusterManager): > }) > self.start_cpg = True > self.cpg_agent = {} > - self.confdb_agent = {} > self.sam_agent = {} > self.votequorum_agent = {} > self.config = CoroConfig () > @@ -226,8 +225,6 @@ class corosync_needle(ClusterManager): > self.cpg_agent[node] = CpgTestAgent(node, self.Env) > self.cpg_agent[node].start() > > - if self.confdb_agent.has_key(node): > - self.confdb_agent[node].restart() > if self.sam_agent.has_key(node): > self.sam_agent[node].restart() > > @@ -376,8 +373,6 @@ class TestAgentComponent(ScenarioComponent): > if self.CM.start_cpg: > self.CM.cpg_agent[node] = CpgTestAgent(node, CM.Env) > self.CM.cpg_agent[node].start() > - self.CM.confdb_agent[node] = ConfdbTestAgent(node, CM.Env) > - self.CM.confdb_agent[node].start() > self.CM.sam_agent[node] = SamTestAgent(node, CM.Env) > self.CM.sam_agent[node].start() > # votequorum agent started as needed. > @@ -393,7 +388,6 @@ class TestAgentComponent(ScenarioComponent): > for node in self.Env["nodes"]: > if self.CM.cpg_agent.has_key(node): > self.CM.cpg_agent[node].stop() > - self.CM.confdb_agent[node].stop() > self.CM.sam_agent[node].stop() > if self.CM.votequorum_agent.has_key(node): > self.CM.votequorum_agent[node].stop() > @@ -626,15 +620,6 @@ class CpgTestAgent(TestAgent): > return self.read () > > ################################################################### > -class ConfdbTestAgent(TestAgent): > - > - def __init__(self, node, Env=None): > - TestAgent.__init__(self, "confdb_test_agent", node, 9035, env=Env) > - self.initialized = False > - self.nodeid = None > - self.send_recv = True > - > -################################################################### > class SamTestAgent(TestAgent): > > def __init__(self, node, Env=None): > diff --git a/cts/corotests.py b/cts/corotests.py > index 8ac3514..7c881a8 100644 > --- a/cts/corotests.py > +++ b/cts/corotests.py > @@ -629,97 +629,24 @@ class ServiceLoadTest(CoroTest): > > return self.success() > > -class ConfdbDispatchDeadlock(CoroTest): > +class CMapDispatchDeadlock(CoroTest): > ''' > - run confdb-dispatch-deadlock.sh > + run cmap-dispatch-deadlock.sh > ''' > def __init__(self, cm): > CoroTest.__init__(self,cm) > - self.name="ConfdbDispatchDeadlock" > + self.name="CMapDispatchDeadlock" > > def __call__(self, node): > self.incr("calls") > > - result = self.CM.rsh(node, "/usr/share/corosync/tests/confdb-dispatch-deadlock.sh") > + result = self.CM.rsh(node, "/usr/share/corosync/tests/cmap-dispatch-deadlock.sh") > if result is 0: > return self.success() > else: > return self.failure('Deadlock detected') > > ################################################################### > -class ConfdbReplaceTest(CoroTest): > - def __init__(self, cm): > - CoroTest.__init__(self, cm) > - self.name="ConfdbReplaceTest" > - > - def __call__(self, node): > - self.incr("calls") > - res = self.CM.confdb_agent[node].set_get_test() > - if 'OK' in res: > - return self.success() > - else: > - return self.failure('set_get_test failed') > - > -################################################################### > -class ConfdbContextTest(CoroTest): > - def __init__(self, cm): > - CoroTest.__init__(self, cm) > - self.name="ConfdbContextTest" > - > - def __call__(self, node): > - self.incr("calls") > - res = self.CM.confdb_agent[node].context_test() > - if 'OK' in res: > - return self.success() > - else: > - return self.failure('context_test failed') > - > - > -################################################################### > -class ConfdbIncrementTest(CoroTest): > - def __init__(self, cm): > - CoroTest.__init__(self, cm) > - self.name="ConfdbIncrementTest" > - > - def __call__(self, node): > - self.incr("calls") > - res = self.CM.confdb_agent[node].increment_decrement_test() > - if 'OK' in res: > - return self.success() > - else: > - return self.failure('increment_decrement_test failed') > - > - > -################################################################### > -class ConfdbObjectFindTest(CoroTest): > - def __init__(self, cm): > - CoroTest.__init__(self, cm) > - self.name="ConfdbObjectFindTest" > - > - def __call__(self, node): > - self.incr("calls") > - res = self.CM.confdb_agent[node].object_find_test() > - if 'OK' in res: > - return self.success() > - else: > - return self.failure('object_find_test failed') > - > - > -################################################################### > -class ConfdbNotificationTest(CoroTest): > - def __init__(self, cm): > - CoroTest.__init__(self, cm) > - self.name="ConfdbNotificationTest" > - > - def __call__(self, node): > - self.incr("calls") > - res = self.CM.confdb_agent[node].notification_test() > - if 'OK' in res: > - return self.success() > - else: > - return self.failure('notification_test failed') > - > -################################################################### > class SamTest1(CoroTest): > def __init__(self, cm): > CoroTest.__init__(self, cm) > @@ -1537,11 +1464,6 @@ GenTestClasses.append(VoteQuorumGoDown) > GenTestClasses.append(VoteQuorumGoUp) > > AllTestClasses = [] > -AllTestClasses.append(ConfdbReplaceTest) > -AllTestClasses.append(ConfdbIncrementTest) > -AllTestClasses.append(ConfdbObjectFindTest) > -AllTestClasses.append(ConfdbNotificationTest) > -AllTestClasses.append(ConfdbContextTest) > AllTestClasses.append(CpgContextTest) > AllTestClasses.append(VoteQuorumContextTest) > AllTestClasses.append(SamTest1) > @@ -1564,7 +1486,7 @@ AllTestClasses.append(ResourcePollAdjust) > AllTestClasses.append(ServiceLoadTest) > AllTestClasses.append(MemLeakObject) > AllTestClasses.append(MemLeakSession) > -#AllTestClasses.append(ConfdbDispatchDeadlock) > +#AllTestClasses.append(CMapDispatchDeadlock) > AllTestClasses.append(FlipTest) > AllTestClasses.append(RestartTest) > AllTestClasses.append(StartOnebyOne) > diff --git a/exec/Makefile.am b/exec/Makefile.am > index 2cc368e..7c63f9c 100644 > --- a/exec/Makefile.am > +++ b/exec/Makefile.am > @@ -44,7 +44,7 @@ endif > > LOGSYS_SRC = logsys.c > ICMAP_SRC = icmap.c > -LCRSO_SRC = objdb.c vsf_ykd.c coroparse.c vsf_quorum.c > +LCRSO_SRC = vsf_ykd.c coroparse.c vsf_quorum.c > LCRSO_OBJS = $(LCRSO_SRC:%.c=%.o) > LCRSO = $(LCRSO_SRC:%.c=%.lcrso) > > @@ -113,11 +113,6 @@ liblogsys.so.$(SONAME): $(LOGSYS_OBJS) > ln -sf liblogsys.so.$(SONAME) liblogsys.so > ln -sf liblogsys.so.$(SONAME) liblogsys.so.$(SOMAJOR) > > -libicmap.so.$(SONAME): $(ICMAP_OBJS) > - $(LD) $(LDFLAGS) -G $(ICMAP_OBJS) -o $@ -lpthread > - ln -sf libicmap.so.$(SONAME) libicmap.so > - ln -sf libicmap.so.$(SONAME) libicmap.so.$(SOMAJOR) > - > else > > %.lcrso: %.o > diff --git a/exec/objdb.c b/exec/objdb.c > deleted file mode 100644 > index 8988600..0000000 > --- a/exec/objdb.c > +++ /dev/null > @@ -1,1857 +0,0 @@ > -/* > - * Copyright (c) 2006 MontaVista Software, Inc. > - * Copyright (c) 2007-2010 Red Hat, Inc. > - * > - * All rights reserved. > - * > - * Author: Steven Dake (sdake@xxxxxxxxxx) > - * > - * 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. > - */ > - > -#define _XOPEN_SOURCE 600 > - > -#include <config.h> > - > -#include <stdio.h> > -#include <errno.h> > -#include <string.h> > - > -#include <pthread.h> > - > -#include <corosync/list.h> > -#include <corosync/hdb.h> > -#include <corosync/lcr/lcr_comp.h> > -#include <corosync/engine/objdb.h> > -#include <corosync/engine/config.h> > -#include <corosync/corotypes.h> > -#include <qb/qbipc_common.h> > - > -#include "main.h" > - > -struct object_key { > - void *key_name; > - size_t key_len; > - void *value; > - size_t value_len; > - objdb_value_types_t value_type; > - struct list_head list; > -}; > - > -struct object_tracker { > - hdb_handle_t object_handle; > - void * data_pt; > - object_track_depth_t depth; > - object_key_change_notify_fn_t key_change_notify_fn; > - object_create_notify_fn_t object_create_notify_fn; > - object_destroy_notify_fn_t object_destroy_notify_fn; > - object_reload_notify_fn_t object_reload_notify_fn; > - struct list_head tracker_list; > - struct list_head object_list; > -}; > - > -struct object_instance { > - void *object_name; > - size_t object_name_len; > - hdb_handle_t object_handle; > - hdb_handle_t parent_handle; > - struct list_head key_head; > - struct list_head child_head; > - struct list_head child_list; > - struct list_head *find_child_list; > - struct list_head *iter_key_list; > - struct list_head *iter_list; > - void *priv; > - struct object_valid *object_valid_list; > - int object_valid_list_entries; > - struct object_key_valid *object_key_valid_list; > - int object_key_valid_list_entries; > - struct list_head track_head; > -}; > - > -struct object_find_instance { > - void *object_name; > - size_t object_len; > - hdb_handle_t *handles_array; > - size_t handles_array_size; > - size_t handles_array_pos; > -}; > - > -struct objdb_iface_ver0 objdb_iface; > -struct list_head objdb_trackers_head; > - > -static int object_destroy (hdb_handle_t object_handle); > - > -DECLARE_HDB_DATABASE (object_instance_database,NULL); > - > -DECLARE_HDB_DATABASE (object_find_instance_database,NULL); > - > -static int objdb_init (void) > -{ > - hdb_handle_t handle; > - struct object_instance *instance; > - int res; > - > - res = hdb_handle_create (&object_instance_database, > - sizeof (struct object_instance), &handle); > - if (res != 0) { > - goto error_exit; > - } > - res = hdb_handle_get (&object_instance_database, > - handle, (void *)&instance); > - if (res != 0) { > - goto error_destroy; > - } > - instance->find_child_list = &instance->child_head; > - instance->object_name = strdup("parent"); > - instance->object_name_len = strlen ("parent"); > - instance->object_handle = handle; > - instance->parent_handle = OBJECT_PARENT_HANDLE; > - instance->priv = NULL; > - instance->object_valid_list = NULL; > - instance->object_valid_list_entries = 0; > - list_init (&instance->key_head); > - list_init (&instance->child_head); > - list_init (&instance->child_list); > - list_init (&instance->track_head); > - list_init (&objdb_trackers_head); > - > - hdb_handle_put (&object_instance_database, handle); > - return (0); > - > -error_destroy: > - hdb_handle_destroy (&object_instance_database, handle); > - > -error_exit: > - return (-1); > -} > - > - > -static void objdb_fini (void) > -{ > - object_destroy (OBJECT_PARENT_HANDLE); > - hdb_destroy (&object_instance_database); > -} > - > -static int _object_notify_deleted_children(struct object_instance *parent_pt) > -{ > - struct list_head *list; > - struct list_head *notify_list; > - int res; > - struct object_instance *obj_pt = NULL; > - struct object_tracker * tracker_pt; > - > - for (list = parent_pt->child_head.next; > - list != &parent_pt->child_head; list = list->next) { > - > - obj_pt = list_entry(list, struct object_instance, > - child_list); > - res = _object_notify_deleted_children(obj_pt); > - if (res) > - return res; > - > - for (notify_list = obj_pt->track_head.next; > - notify_list != &obj_pt->track_head; > - notify_list = notify_list->next) { > - > - tracker_pt = list_entry (notify_list, struct object_tracker, object_list); > - > - if ((tracker_pt != NULL) && > - (tracker_pt->object_destroy_notify_fn != NULL)) > - tracker_pt->object_destroy_notify_fn(parent_pt->object_handle, > - obj_pt->object_name, > - obj_pt->object_name_len, > - tracker_pt->data_pt); > - } > - } > - > - return 0; > -} > - > -static void object_created_notification( > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *name_pt, size_t name_len) > -{ > - struct list_head * list; > - struct object_instance * obj_pt; > - struct object_tracker * tracker_pt; > - hdb_handle_t obj_handle = object_handle; > - > - do { > - if (hdb_handle_get (&object_instance_database, > - obj_handle, (void *)&obj_pt) != 0) { > - return; > - } > - > - for (list = obj_pt->track_head.next; > - list != &obj_pt->track_head; list = list->next) { > - > - tracker_pt = list_entry (list, struct object_tracker, object_list); > - > - if (((obj_handle == parent_object_handle) || > - (tracker_pt->depth == OBJECT_TRACK_DEPTH_RECURSIVE)) && > - (tracker_pt->object_create_notify_fn != NULL)) { > - tracker_pt->object_create_notify_fn(parent_object_handle, > - object_handle, > - name_pt, name_len, > - tracker_pt->data_pt); > - } > - } > - > - hdb_handle_put (&object_instance_database, obj_handle); > - obj_handle = obj_pt->parent_handle; > - } while (obj_handle != OBJECT_PARENT_HANDLE); > -} > - > -static void object_pre_deletion_notification(hdb_handle_t object_handle, > - hdb_handle_t parent_object_handle, > - const void *name_pt, size_t name_len) > -{ > - struct list_head * list; > - struct object_instance * obj_pt; > - struct object_tracker * tracker_pt; > - hdb_handle_t obj_handle = object_handle; > - > - do { > - if (hdb_handle_get (&object_instance_database, > - obj_handle, (void *)&obj_pt) != 0) { > - return; > - } > - > - for (list = obj_pt->track_head.next; > - list != &obj_pt->track_head; list = list->next) { > - > - tracker_pt = list_entry (list, struct object_tracker, object_list); > - > - if (((obj_handle == parent_object_handle) || > - (tracker_pt->depth == OBJECT_TRACK_DEPTH_RECURSIVE)) && > - (tracker_pt->object_destroy_notify_fn != NULL)) { > - tracker_pt->object_destroy_notify_fn( > - parent_object_handle, > - name_pt, name_len, > - tracker_pt->data_pt); > - } > - } > - /* notify child object listeners */ > - if (obj_handle == object_handle) > - _object_notify_deleted_children(obj_pt); > - > - obj_handle = obj_pt->parent_handle; > - hdb_handle_put (&object_instance_database, obj_pt->object_handle); > - } while (obj_handle != OBJECT_PARENT_HANDLE); > -} > - > -static void object_key_changed_notification(hdb_handle_t object_handle, > - const void *name_pt, size_t name_len, > - const void *value_pt, size_t value_len, > - object_change_type_t type) > -{ > - struct list_head * list; > - struct object_instance * obj_pt; > - struct object_instance * owner_pt = NULL; > - struct object_tracker * tracker_pt; > - hdb_handle_t obj_handle = object_handle; > - > - do { > - if (hdb_handle_get (&object_instance_database, > - obj_handle, (void *)&obj_pt) != 0) { > - return; > - } > - > - if (owner_pt == NULL) > - owner_pt = obj_pt; > - > - for (list = obj_pt->track_head.next; > - list != &obj_pt->track_head; list = list->next) { > - > - tracker_pt = list_entry (list, struct object_tracker, object_list); > - > - if (((obj_handle == object_handle) || > - (tracker_pt->depth == OBJECT_TRACK_DEPTH_RECURSIVE)) && > - (tracker_pt->key_change_notify_fn != NULL)) > - tracker_pt->key_change_notify_fn(type, obj_pt->parent_handle, object_handle, > - owner_pt->object_name, owner_pt->object_name_len, > - name_pt, name_len, > - value_pt, value_len, > - tracker_pt->data_pt); > - } > - > - obj_handle = obj_pt->parent_handle; > - hdb_handle_put (&object_instance_database, obj_pt->object_handle); > - > - } while (obj_handle != OBJECT_PARENT_HANDLE); > -} > - > -static void object_reload_notification(int startstop, int flush) > -{ > - struct list_head * list, *tmp; > - struct list_head tmplist; > - struct object_instance * obj_pt; > - struct object_tracker * tracker_pt; > - struct object_tracker * tmptracker_pt; > - > - if (hdb_handle_get (&object_instance_database, > - OBJECT_PARENT_HANDLE, (void *)&obj_pt) != 0) { > - return; > - } > - > - /* > - * Make a copy of the list > - * so that items can be added & removed in the callbacks > - */ > - list_init(&tmplist); > - for (list = obj_pt->track_head.next; > - list != &obj_pt->track_head; list = list->next) { > - > - tracker_pt = list_entry (list, struct object_tracker, object_list); > - if (tracker_pt->object_reload_notify_fn != NULL) { > - tmptracker_pt = malloc(sizeof(*tracker_pt)); > - if (tmptracker_pt) { > - list_add(&tmptracker_pt->object_list, &tmplist); > - tmptracker_pt->object_reload_notify_fn = tracker_pt->object_reload_notify_fn; > - tmptracker_pt->data_pt = tracker_pt->data_pt; > - } > - } > - } > - > - for (list = tmplist.next, tmp = list->next; > - list != &tmplist; list = tmp, tmp = list->next) { > - > - tracker_pt = list_entry (list, struct object_tracker, object_list); > - > - tracker_pt->object_reload_notify_fn(startstop, flush, > - tracker_pt->data_pt); > - free(tracker_pt); > - } > - hdb_handle_put (&object_instance_database, OBJECT_PARENT_HANDLE); > -} > - > - > -/* > - * object db create/destroy/set > - */ > -static int object_create ( > - hdb_handle_t parent_object_handle, > - hdb_handle_t *object_handle, > - const void *object_name, > - size_t object_name_len) > -{ > - struct object_instance *object_instance; > - struct object_instance *parent_instance; > - int res; > - int found = 0; > - int i; > - > - res = hdb_handle_get (&object_instance_database, > - parent_object_handle, (void *)&parent_instance); > - if (res != 0) { > - goto error_exit; > - } > - > - /* > - * Do validation check if validation is configured for the parent object > - */ > - if (parent_instance->object_valid_list_entries) { > - for (i = 0; i < parent_instance->object_valid_list_entries; i++) { > - if ((object_name_len == > - parent_instance->object_valid_list[i].object_len) && > - (memcmp (object_name, > - parent_instance->object_valid_list[i].object_name, > - object_name_len) == 0)) { > - > - found = 1; > - break; > - } > - } > - > - /* > - * Item not found in validation list > - */ > - if (found == 0) { > - goto error_object_put; > - } > - } > - > - > - res = hdb_handle_create (&object_instance_database, > - sizeof (struct object_instance), object_handle); > - if (res != 0) { > - goto error_object_put; > - } > - > - res = hdb_handle_get (&object_instance_database, > - *object_handle, (void *)&object_instance); > - if (res != 0) { > - goto error_destroy; > - } > - list_init (&object_instance->key_head); > - list_init (&object_instance->child_head); > - list_init (&object_instance->child_list); > - list_init (&object_instance->track_head); > - object_instance->object_name = malloc (object_name_len); > - if (object_instance->object_name == 0) { > - goto error_put_destroy; > - } > - memcpy (object_instance->object_name, object_name, object_name_len); > - > - object_instance->object_name_len = object_name_len; > - > - list_add_tail (&object_instance->child_list, &parent_instance->child_head); > - > - object_instance->object_handle = *object_handle; > - object_instance->find_child_list = &object_instance->child_head; > - object_instance->iter_key_list = &object_instance->key_head; > - object_instance->iter_list = &object_instance->child_head; > - object_instance->priv = NULL; > - object_instance->object_valid_list = NULL; > - object_instance->object_valid_list_entries = 0; > - object_instance->parent_handle = parent_object_handle; > - > - hdb_handle_put (&object_instance_database, *object_handle); > - > - hdb_handle_put (&object_instance_database, parent_object_handle); > - object_created_notification( > - object_instance->parent_handle, > - object_instance->object_handle, > - object_instance->object_name, > - object_instance->object_name_len); > - return (0); > - > -error_put_destroy: > - hdb_handle_put (&object_instance_database, *object_handle); > - > -error_destroy: > - hdb_handle_destroy (&object_instance_database, *object_handle); > - > -error_object_put: > - hdb_handle_put (&object_instance_database, parent_object_handle); > - > -error_exit: > - return (-1); > -} > - > -static int object_priv_set ( > - hdb_handle_t object_handle, > - void *priv) > -{ > - int res; > - struct object_instance *object_instance; > - > - res = hdb_handle_get (&object_instance_database, > - object_handle, (void *)&object_instance); > - if (res != 0) { > - goto error_exit; > - } > - > - object_instance->priv = priv; > - > - hdb_handle_put (&object_instance_database, object_handle); > - return (0); > - > -error_exit: > - return (-1); > -} > - > -static int object_key_create_typed( > - hdb_handle_t object_handle, > - const char *key_name, > - const void *value, > - size_t value_len, > - objdb_value_types_t value_type) > -{ > - struct object_instance *instance; > - struct object_key *object_key; > - int res; > - struct list_head *list; > - int found = 0; > - int i; > - size_t key_len = strlen(key_name); > - size_t expected_size; > - int test_size_by_type = CS_TRUE; > - > - res = hdb_handle_get (&object_instance_database, > - object_handle, (void *)&instance); > - if (res != 0) { > - goto error_exit; > - } > - > - switch (value_type) { > - case OBJDB_VALUETYPE_INT16: > - expected_size = sizeof (int16_t); > - break; > - case OBJDB_VALUETYPE_UINT16: > - expected_size = sizeof (uint16_t); > - break; > - case OBJDB_VALUETYPE_INT32: > - expected_size = sizeof (int32_t); > - break; > - case OBJDB_VALUETYPE_UINT32: > - expected_size = sizeof (uint32_t); > - break; > - case OBJDB_VALUETYPE_INT64: > - expected_size = sizeof (int64_t); > - break; > - case OBJDB_VALUETYPE_UINT64: > - expected_size = sizeof (uint64_t); > - break; > - case OBJDB_VALUETYPE_FLOAT: > - expected_size = sizeof (float); > - break; > - case OBJDB_VALUETYPE_DOUBLE: > - expected_size = sizeof (double); > - break; > - case OBJDB_VALUETYPE_ANY: > - default: > - test_size_by_type = CS_FALSE; > - break; > - } > - if (test_size_by_type) { > - if (expected_size != value_len) { > - //printf ("%s exp:%d != len:%d\n", key_name, expected_size, value_len); > - goto error_put; > - } > - } > - > - /* > - * Do validation check if validation is configured for the parent object > - */ > - if (instance->object_key_valid_list_entries) { > - for (i = 0; i < instance->object_key_valid_list_entries; i++) { > - if ((key_len == > - instance->object_key_valid_list[i].key_len) && > - (memcmp (key_name, > - instance->object_key_valid_list[i].key_name, > - key_len) == 0)) { > - > - found = 1; > - break; > - } > - } > - > - /* > - * Item not found in validation list > - */ > - if (found == 0) { > - goto error_put; > - } else { > - if (instance->object_key_valid_list[i].validate_callback) { > - res = instance->object_key_valid_list[i].validate_callback ( > - key_name, key_len, value, value_len); > - if (res != 0) { > - goto error_put; > - } > - } > - } > - } > - > - /* See if it already exists */ > - found = 0; > - for (list = instance->key_head.next; > - list != &instance->key_head; list = list->next) { > - > - object_key = list_entry (list, struct object_key, list); > - > - if ((object_key->key_len == key_len) && > - (memcmp (object_key->key_name, key_name, key_len) == 0)) { > - found = 1; > - break; > - } > - } > - > - if (found) { > - free(object_key->value); > - } > - else { > - object_key = malloc (sizeof (struct object_key)); > - if (object_key == 0) { > - goto error_put; > - } > - object_key->key_name = malloc (key_len + 1); > - if (object_key->key_name == 0) { > - goto error_put_object; > - } > - memcpy (object_key->key_name, key_name, key_len + 1); > - list_init (&object_key->list); > - list_add_tail (&object_key->list, &instance->key_head); > - } > - object_key->value = malloc (value_len); > - if (object_key->value == 0) { > - goto error_put_key; > - } > - memcpy (object_key->value, value, value_len); > - > - object_key->key_len = key_len; > - object_key->value_len = value_len; > - object_key->value_type = value_type; > - > - object_key_changed_notification(object_handle, key_name, key_len, > - value, value_len, OBJECT_KEY_CREATED); > - hdb_handle_put (&object_instance_database, object_handle); > - return (0); > - > -error_put_key: > - free (object_key->key_name); > - > -error_put_object: > - free (object_key); > - > -error_put: > - hdb_handle_put (&object_instance_database, object_handle); > - > -error_exit: > - return (-1); > -} > - > -static int object_key_create ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len, > - const void *value, > - size_t value_len) > -{ > - char *key_name_terminated = NULL; > - char *key_name_str = (char*)key_name; > - int ret; > - > - if (key_name_str[key_len-1] != '\0') { > - key_name_terminated = malloc (key_len + 1); > - memcpy (key_name_terminated, key_name, key_len); > - key_name_terminated[key_len] = '\0'; > - key_name_str = key_name_terminated; > - } > - > - ret = object_key_create_typed (object_handle, key_name_str, > - value, value_len, OBJDB_VALUETYPE_ANY); > - if (key_name_terminated) { > - free (key_name_terminated); > - } > - return ret; > -} > - > -static int _clear_object(struct object_instance *instance) > -{ > - struct list_head *list; > - int res; > - struct object_instance *find_instance = NULL; > - struct object_key *object_key = NULL; > - struct object_tracker *tracker_pt = NULL; > - > - for (list = instance->key_head.next; > - list != &instance->key_head; ) { > - > - object_key = list_entry (list, struct object_key, > - list); > - > - list = list->next; > - > - list_del(&object_key->list); > - free(object_key->key_name); > - free(object_key->value); > - free(object_key); > - } > - > - for (list = instance->track_head.next; > - list != &instance->track_head;) { > - > - tracker_pt = list_entry (list, > - struct object_tracker, object_list); > - > - list = list->next; > - > - list_del(&tracker_pt->tracker_list); > - list_del(&tracker_pt->object_list); > - free(tracker_pt); > - } > - > - for (list = instance->child_head.next; > - list != &instance->child_head; ) { > - > - find_instance = list_entry (list, struct object_instance, > - child_list); > - res = _clear_object(find_instance); > - if (res) > - return res; > - > - list = list->next; > - > - list_del(&find_instance->child_list); > - free(find_instance->object_name); > - hdb_handle_destroy (&object_instance_database, find_instance->object_handle); > - } > - > - return 0; > -} > - > -static int object_destroy ( > - hdb_handle_t object_handle) > -{ > - struct object_instance *instance; > - int res; > - > - res = hdb_handle_get (&object_instance_database, > - object_handle, (void *)&instance); > - if (res != 0) { > - return (res); > - } > - > - object_pre_deletion_notification(object_handle, > - instance->parent_handle, > - instance->object_name, > - instance->object_name_len); > - > - /* Recursively clear sub-objects & keys */ > - res = _clear_object(instance); > - > - list_del(&instance->child_list); > - free(instance->object_name); > - hdb_handle_put (&object_instance_database, object_handle); > - hdb_handle_destroy (&object_instance_database, object_handle); > - > - return (res); > -} > - > -static int object_valid_set ( > - hdb_handle_t object_handle, > - struct object_valid *object_valid_list, > - size_t object_valid_list_entries) > -{ > - struct object_instance *instance; > - int res; > - > - res = hdb_handle_get (&object_instance_database, > - object_handle, (void *)&instance); > - if (res != 0) { > - goto error_exit; > - } > - > - instance->object_valid_list = object_valid_list; > - instance->object_valid_list_entries = object_valid_list_entries; > - > - hdb_handle_put (&object_instance_database, object_handle); > - > - return (0); > - > -error_exit: > - return (-1); > -} > - > -static int object_key_valid_set ( > - hdb_handle_t object_handle, > - struct object_key_valid *object_key_valid_list, > - size_t object_key_valid_list_entries) > -{ > - struct object_instance *instance; > - int res; > - > - res = hdb_handle_get (&object_instance_database, > - object_handle, (void *)&instance); > - if (res != 0) { > - goto error_exit; > - } > - > - instance->object_key_valid_list = object_key_valid_list; > - instance->object_key_valid_list_entries = object_key_valid_list_entries; > - > - hdb_handle_put (&object_instance_database, object_handle); > - > - return (0); > - > -error_exit: > - return (-1); > -} > - > -/* > - * object db reading > - */ > -static int object_find_create ( > - hdb_handle_t object_handle, > - const void *object_name, > - size_t object_len, > - hdb_handle_t *object_find_handle) > -{ > - int res; > - struct object_instance *iter_obj_inst; > - struct object_instance *object_instance; > - struct object_find_instance *object_find_instance; > - struct list_head *list; > - hdb_handle_t *handles_array, *handles_array_realloc; > - size_t ha_len; > - size_t ha_used; > - > - res = hdb_handle_get (&object_instance_database, > - object_handle, (void *)&object_instance); > - if (res != 0) { > - goto error_exit; > - } > - > - res = hdb_handle_create (&object_find_instance_database, > - sizeof (struct object_find_instance), object_find_handle); > - if (res != 0) { > - goto error_put; > - } > - res = hdb_handle_get (&object_find_instance_database, > - *object_find_handle, (void *)&object_find_instance); > - if (res != 0) { > - goto error_destroy; > - } > - > - object_find_instance->object_name = (char *)object_name; > - object_find_instance->object_len = object_len; > - > - ha_len = ha_used = 0; > - handles_array = NULL; > - > - for (list = object_instance->child_head.next; > - list != &object_instance->child_head; list = list->next) { > - > - iter_obj_inst = list_entry (list, struct object_instance, > - child_list); > - > - if (object_find_instance->object_len == 0 || > - ((iter_obj_inst->object_name_len == > - object_find_instance->object_len) && > - > - (memcmp (iter_obj_inst->object_name, > - object_find_instance->object_name, > - object_find_instance->object_len) == 0))) { > - > - /* > - * Add handle to list > - */ > - if (ha_used + 1 > ha_len) { > - ha_len = ha_len * 2 + 1; > - if ((handles_array_realloc = > - realloc (handles_array, ha_len * sizeof (hdb_handle_t))) == > - NULL) { > - goto error_ha_free; > - } > - handles_array = handles_array_realloc; > - } > - > - handles_array[ha_used] = > - iter_obj_inst->object_handle; > - > - ha_used++; > - } > - } > - > - object_find_instance->handles_array_size = ha_used; > - object_find_instance->handles_array_pos = 0; > - object_find_instance->handles_array = handles_array; > - > - hdb_handle_put (&object_instance_database, object_handle); > - hdb_handle_put (&object_find_instance_database, *object_find_handle); > - > - return (0); > - > -error_ha_free: > - free(handles_array); > - > -error_destroy: > - hdb_handle_destroy (&object_instance_database, *object_find_handle); > - > -error_put: > - hdb_handle_put (&object_instance_database, object_handle); > - > -error_exit: > - return (-1); > -} > - > -static int object_find_next ( > - hdb_handle_t object_find_handle, > - hdb_handle_t *object_handle) > -{ > - int res; > - struct object_find_instance *object_find_instance; > - struct object_instance *object_instance = NULL; > - int found = 0; > - size_t pos; > - > - res = hdb_handle_get (&object_find_instance_database, > - object_find_handle, (void *)&object_find_instance); > - if (res != 0) { > - goto error_exit; > - } > - > - for (pos = object_find_instance->handles_array_pos; !found && > - pos < object_find_instance->handles_array_size; pos++) { > - *object_handle = object_find_instance->handles_array[pos]; > - > - res = hdb_handle_get (&object_instance_database, > - *object_handle, (void *)&object_instance); > - if (res != 0) { > - continue; > - } > - > - if (object_find_instance->object_len == 0 || > - ((object_instance->object_name_len == > - object_find_instance->object_len) && > - > - (memcmp (object_instance->object_name, > - object_find_instance->object_name, > - object_find_instance->object_len) == 0))) { > - > - found = 1; > - } > - > - hdb_handle_put (&object_instance_database, *object_handle); > - } > - > - object_find_instance->handles_array_pos = pos; > - > - hdb_handle_put (&object_find_instance_database, object_find_handle); > - if (found) { > - *object_handle = object_instance->object_handle; > - res = 0; > - } else { > - res = -1; > - } > - return (res); > - > -error_exit: > - return (-1); > -} > - > -static int object_find_destroy ( > - hdb_handle_t object_find_handle) > -{ > - struct object_find_instance *object_find_instance; > - int res; > - > - res = hdb_handle_get (&object_find_instance_database, > - object_find_handle, (void *)&object_find_instance); > - if (res != 0) { > - goto error_exit; > - } > - > - free(object_find_instance->handles_array); > - > - hdb_handle_put(&object_find_instance_database, object_find_handle); > - hdb_handle_destroy(&object_find_instance_database, object_find_handle); > - > - return (0); > - > -error_exit: > - return (-1); > -} > - > -static int object_key_get_typed ( > - hdb_handle_t object_handle, > - const char *key_name, > - void **value, > - size_t *value_len, > - objdb_value_types_t * type) > -{ > - int res = 0; > - struct object_instance *instance; > - struct object_key *object_key = NULL; > - struct list_head *list; > - int found = 0; > - size_t key_len = strlen(key_name); > - > - res = hdb_handle_get (&object_instance_database, > - object_handle, (void *)&instance); > - if (res != 0) { > - goto error_exit; > - } > - for (list = instance->key_head.next; > - list != &instance->key_head; list = list->next) { > - > - object_key = list_entry (list, struct object_key, list); > - > - if ((object_key->key_len == key_len) && > - (memcmp (object_key->key_name, key_name, key_len) == 0)) { > - found = 1; > - break; > - } > - } > - if (found) { > - *value = object_key->value; > - if (value_len) { > - *value_len = object_key->value_len; > - } > - *type = object_key->value_type; > - } > - else { > - res = -1; > - } > - > - hdb_handle_put (&object_instance_database, object_handle); > - return (res); > - > -error_exit: > - return (-1); > -} > - > -static int object_key_get ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len, > - void **value, > - size_t *value_len) > -{ > - objdb_value_types_t t; > - int ret; > - char *key_name_str = (char*)key_name; > - char *key_name_terminated = NULL; > - > - if (key_name_str[key_len-1] != '\0') { > - key_name_terminated = malloc (key_len + 1); > - memcpy (key_name_terminated, key_name, key_len); > - key_name_terminated[key_len] = '\0'; > - key_name_str = key_name_terminated; > - } > - > - ret = object_key_get_typed(object_handle, > - key_name_str, > - value, value_len, &t); > - if (key_name_terminated) { > - free (key_name_terminated); > - } > - return ret; > -} > - > -static int object_key_increment ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len, > - unsigned int *value) > -{ > - int res = 0; > - struct object_instance *instance; > - struct object_key *object_key = NULL; > - struct list_head *list; > - int found = 0; > - > - res = hdb_handle_get (&object_instance_database, > - object_handle, (void *)&instance); > - if (res != 0) { > - goto error_exit; > - } > - for (list = instance->key_head.next; > - list != &instance->key_head; list = list->next) { > - > - object_key = list_entry (list, struct object_key, list); > - > - if ((object_key->key_len == key_len) && > - (memcmp (object_key->key_name, key_name, key_len) == 0)) { > - found = 1; > - break; > - } > - } > - > - if (found) { > - switch (object_key->value_type) { > - case OBJDB_VALUETYPE_INT16: > - (*(int16_t *)object_key->value)++; > - break; > - case OBJDB_VALUETYPE_UINT16: > - (*(uint16_t *)object_key->value)++; > - break; > - case OBJDB_VALUETYPE_INT32: > - (*(int32_t *)object_key->value)++; > - break; > - case OBJDB_VALUETYPE_UINT32: > - (*(uint32_t *)object_key->value)++; > - break; > - case OBJDB_VALUETYPE_INT64: > - (*(int64_t *)object_key->value)++; > - break; > - case OBJDB_VALUETYPE_UINT64: > - (*(uint64_t *)object_key->value)++; > - break; > - case OBJDB_VALUETYPE_ANY: > - /* for backwards compatibilty */ > - if (object_key->value_len == sizeof(int)) { > - (*(int *)object_key->value)++; > - } > - else { > - res = -1; > - } > - break; > - default: > - res = -1; > - break; > - } > - if (res == 0) { > - /* nasty, not sure why we need to return this typed > - * instead of void* */ > - *value = *(int *)object_key->value; > - } > - } > - else { > - res = -1; > - } > - > - hdb_handle_put (&object_instance_database, object_handle); > - if (res == 0) { > - object_key_changed_notification (object_handle, key_name, key_len, > - object_key->value, object_key->value_len, OBJECT_KEY_REPLACED); > - } > - return (res); > - > -error_exit: > - return (-1); > -} > - > -static int object_key_decrement ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len, > - unsigned int *value) > -{ > - int res = 0; > - struct object_instance *instance; > - struct object_key *object_key = NULL; > - struct list_head *list; > - int found = 0; > - > - res = hdb_handle_get (&object_instance_database, > - object_handle, (void *)&instance); > - if (res != 0) { > - goto error_exit; > - } > - for (list = instance->key_head.next; > - list != &instance->key_head; list = list->next) { > - > - object_key = list_entry (list, struct object_key, list); > - > - if ((object_key->key_len == key_len) && > - (memcmp (object_key->key_name, key_name, key_len) == 0)) { > - found = 1; > - break; > - } > - } > - > - > - if (found) { > - switch (object_key->value_type) { > - case OBJDB_VALUETYPE_INT16: > - (*(int16_t *)object_key->value)--; > - break; > - case OBJDB_VALUETYPE_UINT16: > - (*(uint16_t *)object_key->value)--; > - break; > - case OBJDB_VALUETYPE_INT32: > - (*(int32_t *)object_key->value)--; > - break; > - case OBJDB_VALUETYPE_UINT32: > - (*(uint32_t *)object_key->value)--; > - break; > - case OBJDB_VALUETYPE_INT64: > - (*(int64_t *)object_key->value)--; > - break; > - case OBJDB_VALUETYPE_UINT64: > - (*(uint64_t *)object_key->value)--; > - break; > - case OBJDB_VALUETYPE_ANY: > - /* for backwards compatibilty */ > - if (object_key->value_len == sizeof(int)) { > - (*(int *)object_key->value)--; > - } > - else { > - res = -1; > - } > - break; > - default: > - res = -1; > - break; > - } > - if (res == 0) { > - /* nasty, not sure why we need to return this typed > - * instead of void* */ > - *value = *(int *)object_key->value; > - } > - } > - else { > - res = -1; > - } > - > - hdb_handle_put (&object_instance_database, object_handle); > - if (res == 0) { > - object_key_changed_notification (object_handle, key_name, key_len, > - object_key->value, object_key->value_len, OBJECT_KEY_REPLACED); > - } > - return (res); > - > -error_exit: > - return (-1); > -} > - > -static int object_key_delete ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len) > -{ > - int res; > - int ret = 0; > - struct object_instance *instance; > - struct object_key *object_key = NULL; > - struct list_head *list; > - int found = 0; > - > - res = hdb_handle_get (&object_instance_database, > - object_handle, (void *)&instance); > - if (res != 0) { > - goto error_exit; > - } > - for (list = instance->key_head.next; > - list != &instance->key_head; list = list->next) { > - > - object_key = list_entry (list, struct object_key, list); > - > - if ((object_key->key_len == key_len) && > - (memcmp (object_key->key_name, key_name, key_len) == 0)) { > - found = 1; > - break; > - } > - } > - if (found) { > - list_del(&object_key->list); > - free(object_key->key_name); > - free(object_key->value); > - free(object_key); > - } > - else { > - ret = -1; > - errno = ENOENT; > - } > - > - hdb_handle_put (&object_instance_database, object_handle); > - if (ret == 0) { > - object_key_changed_notification(object_handle, key_name, key_len, > - NULL, 0, OBJECT_KEY_DELETED); > - } > - return (ret); > - > -error_exit: > - return (-1); > -} > - > -static int object_key_replace ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len, > - const void *new_value, > - size_t new_value_len) > -{ > - int res; > - int ret = 0; > - struct object_instance *instance; > - struct object_key *object_key = NULL; > - struct list_head *list; > - int found = 0; > - int value_changed = 0; > - > - res = hdb_handle_get (&object_instance_database, > - object_handle, (void *)&instance); > - if (res != 0) { > - goto error_exit; > - } > - for (list = instance->key_head.next; > - list != &instance->key_head; list = list->next) { > - > - object_key = list_entry (list, struct object_key, list); > - > - if ((object_key->key_len == key_len) && > - (memcmp (object_key->key_name, key_name, key_len) == 0)) { > - found = 1; > - break; > - } > - } > - > - if (found) { > - int i; > - int found_validator = 0; > - > - /* > - * Do validation check if validation is configured for the parent object > - */ > - if (instance->object_key_valid_list_entries) { > - for (i = 0; i < instance->object_key_valid_list_entries; i++) { > - if ((key_len == > - instance->object_key_valid_list[i].key_len) && > - (memcmp (key_name, > - instance->object_key_valid_list[i].key_name, > - key_len) == 0)) { > - > - found_validator = 1; > - break; > - } > - } > - > - /* > - * Item not found in validation list > - */ > - if (found_validator == 0) { > - goto error_put; > - } else { > - if (instance->object_key_valid_list[i].validate_callback) { > - res = instance->object_key_valid_list[i].validate_callback ( > - key_name, key_len, new_value, new_value_len); > - if (res != 0) { > - goto error_put; > - } > - } > - } > - } > - > - if (new_value_len != object_key->value_len) { > - void *replacement_value; > - replacement_value = malloc(new_value_len); > - if (!replacement_value) > - goto error_exit; > - free(object_key->value); > - object_key->value = replacement_value; > - memset (object_key->value, 0, new_value_len); > - object_key->value_len = new_value_len; > - } > - if (memcmp (object_key->value, new_value, new_value_len) == 0) { > - value_changed = 0; > - } > - else { > - memcpy(object_key->value, new_value, new_value_len); > - object_key->value_len = new_value_len; > - value_changed = 1; > - } > - } > - else { > - ret = -1; > - errno = ENOENT; > - } > - > - hdb_handle_put (&object_instance_database, object_handle); > - if (ret == 0 && value_changed) { > - object_key_changed_notification (object_handle, key_name, key_len, > - new_value, new_value_len, OBJECT_KEY_REPLACED); > - } > - return (ret); > - > -error_put: > - hdb_handle_put (&object_instance_database, object_handle); > -error_exit: > - return (-1); > -} > - > -static int object_priv_get ( > - hdb_handle_t object_handle, > - void **priv) > -{ > - int res; > - struct object_instance *object_instance; > - > - res = hdb_handle_get (&object_instance_database, > - object_handle, (void *)&object_instance); > - if (res != 0) { > - goto error_exit; > - } > - > - *priv = object_instance->priv; > - > - hdb_handle_put (&object_instance_database, object_handle); > - return (0); > - > -error_exit: > - return (-1); > -} > - > -static int _dump_object(struct object_instance *instance, FILE *file, int depth) > -{ > - struct list_head *list; > - int res; > - int i; > - struct object_instance *find_instance = NULL; > - struct object_key *object_key = NULL; > - char stringbuf1[1024]; > - char stringbuf2[1024]; > - > - memcpy(stringbuf1, instance->object_name, instance->object_name_len); > - stringbuf1[instance->object_name_len] = '\0'; > - > - for (i=0; i<depth; i++) > - fprintf(file, " "); > - > - if (instance->object_handle != OBJECT_PARENT_HANDLE) > - fprintf(file, "%s {\n", stringbuf1); > - > - for (list = instance->key_head.next; > - list != &instance->key_head; list = list->next) { > - > - object_key = list_entry (list, struct object_key, > - list); > - > - memcpy(stringbuf1, object_key->key_name, object_key->key_len); > - stringbuf1[object_key->key_len] = '\0'; > - > - switch (object_key->value_type) { > - case OBJDB_VALUETYPE_INT16: > - snprintf (stringbuf2, sizeof(int), "%hd", > - *(unsigned int*)object_key->value); > - break; > - case OBJDB_VALUETYPE_UINT16: > - snprintf (stringbuf2, sizeof(int), "%hu", > - *(unsigned int*)object_key->value); > - break; > - case OBJDB_VALUETYPE_INT32: > - snprintf (stringbuf2, sizeof(int), "%d", > - *(int*)object_key->value); > - break; > - case OBJDB_VALUETYPE_UINT32: > - snprintf (stringbuf2, sizeof(int), "%u", > - *(unsigned int*)object_key->value); > - break; > - case OBJDB_VALUETYPE_INT64: > - snprintf (stringbuf2, sizeof(int), "%ld", > - *(long int*)object_key->value); > - break; > - case OBJDB_VALUETYPE_UINT64: > - snprintf (stringbuf2, sizeof(int), "%lu", > - *(unsigned long int*)object_key->value); > - break; > - default: > - case OBJDB_VALUETYPE_STRING: > - case OBJDB_VALUETYPE_ANY: > - memcpy(stringbuf2, object_key->value, object_key->value_len); > - stringbuf2[object_key->value_len] = '\0'; > - break; > - } > - > - for (i=0; i<depth+1; i++) > - fprintf(file, " "); > - > - fprintf(file, "%s: %s\n", stringbuf1, stringbuf2); > - } > - > - for (list = instance->child_head.next; > - list != &instance->child_head; list = list->next) { > - > - find_instance = list_entry (list, struct object_instance, > - child_list); > - res = _dump_object(find_instance, file, depth+1); > - if (res) > - return res; > - } > - for (i=0; i<depth; i++) > - fprintf(file, " "); > - > - if (instance->object_handle != OBJECT_PARENT_HANDLE) > - fprintf(file, "}\n"); > - > - return 0; > -} > - > -static int object_key_iter_reset(hdb_handle_t object_handle) > -{ > - int res; > - struct object_instance *instance; > - > - res = hdb_handle_get (&object_instance_database, > - object_handle, (void *)&instance); > - if (res != 0) { > - goto error_exit; > - } > - instance->iter_key_list = &instance->key_head; > - > - hdb_handle_put (&object_instance_database, object_handle); > - return (0); > - > -error_exit: > - return (-1); > -} > - > -static int object_key_iter_typed (hdb_handle_t parent_object_handle, > - char **key_name, > - void **value, > - size_t *value_len, > - objdb_value_types_t *type) > -{ > - int res; > - struct object_instance *instance; > - struct object_key *find_key = NULL; > - struct list_head *list; > - unsigned int found = 0; > - > - res = hdb_handle_get (&object_instance_database, > - parent_object_handle, (void *)&instance); > - if (res != 0) { > - goto error_exit; > - } > - res = -ENOENT; > - list = instance->iter_key_list->next; > - if (list != &instance->key_head) { > - find_key = list_entry (list, struct object_key, list); > - found = 1; > - } > - instance->iter_key_list = list; > - if (found) { > - *key_name = find_key->key_name; > - *value = find_key->value; > - *type = find_key->value_type; > - if (value_len) > - *value_len = find_key->value_len; > - res = 0; > - } > - else { > - res = -1; > - } > - > - hdb_handle_put (&object_instance_database, parent_object_handle); > - return (res); > - > -error_exit: > - return (-1); > -} > - > -static int object_key_iter(hdb_handle_t parent_object_handle, > - void **key_name, > - size_t *key_len, > - void **value, > - size_t *value_len) > -{ > - objdb_value_types_t t; > - int ret; > - char *str; > - ret = object_key_iter_typed (parent_object_handle, > - (char**)key_name, value, value_len, &t); > - if (!ret) { > - str = *key_name; > - *key_len = strlen(str); > - } > - return ret; > -} > - > -static int object_key_iter_from(hdb_handle_t parent_object_handle, > - hdb_handle_t start_pos, > - void **key_name, > - size_t *key_len, > - void **value, > - size_t *value_len) > -{ > - unsigned int pos = 0; > - int res; > - struct object_instance *instance; > - struct object_key *find_key = NULL; > - struct list_head *list; > - unsigned int found = 0; > - > - res = hdb_handle_get (&object_instance_database, > - parent_object_handle, (void *)&instance); > - if (res != 0) { > - goto error_exit; > - } > - res = -ENOENT; > - > - for (list = instance->key_head.next; > - list != &instance->key_head; list = list->next) { > - > - find_key = list_entry (list, struct object_key, list); > - > - if (pos++ == start_pos) { > - found = 1; > - break; > - } > - } > - > - if (found) { > - *key_name = find_key->key_name; > - if (key_len) > - *key_len = find_key->key_len; > - *value = find_key->value; > - if (value_len) > - *value_len = find_key->value_len; > - res = 0; > - } > - else { > - res = -1; > - } > - > - hdb_handle_put (&object_instance_database, parent_object_handle); > - return (res); > - > -error_exit: > - return (-1); > -} > - > - > -static int object_parent_get(hdb_handle_t object_handle, > - hdb_handle_t *parent_handle) > -{ > - struct object_instance *instance; > - int res; > - > - res = hdb_handle_get (&object_instance_database, > - object_handle, (void *)&instance); > - if (res != 0) { > - return (res); > - } > - > - if (object_handle == OBJECT_PARENT_HANDLE) > - *parent_handle = 0; > - else > - *parent_handle = instance->parent_handle; > - > - hdb_handle_put (&object_instance_database, object_handle); > - > - return (0); > -} > - > -static int object_name_get(hdb_handle_t object_handle, > - char *object_name, > - size_t *object_name_len) > -{ > - struct object_instance *instance; > - int res; > - > - res = hdb_handle_get (&object_instance_database, > - object_handle, (void *)&instance); > - if (res != 0) { > - return (res); > - } > - > - memcpy(object_name, instance->object_name, instance->object_name_len); > - *object_name_len = instance->object_name_len; > - > - hdb_handle_put (&object_instance_database, object_handle); > - > - return (0); > -} > - > - > -static int object_track_start(hdb_handle_t object_handle, > - object_track_depth_t depth, > - object_key_change_notify_fn_t key_change_notify_fn, > - object_create_notify_fn_t object_create_notify_fn, > - object_destroy_notify_fn_t object_destroy_notify_fn, > - object_reload_notify_fn_t object_reload_notify_fn, > - void * priv_data_pt) > -{ > - struct object_instance *instance; > - int res; > - struct object_tracker * tracker_pt; > - > - res = hdb_handle_get (&object_instance_database, > - object_handle, (void *)&instance); > - if (res != 0) { > - return (res); > - } > - tracker_pt = malloc(sizeof(struct object_tracker)); > - > - tracker_pt->depth = depth; > - tracker_pt->object_handle = object_handle; > - tracker_pt->key_change_notify_fn = key_change_notify_fn; > - tracker_pt->object_create_notify_fn = object_create_notify_fn; > - tracker_pt->object_destroy_notify_fn = object_destroy_notify_fn; > - tracker_pt->object_reload_notify_fn = object_reload_notify_fn; > - tracker_pt->data_pt = priv_data_pt; > - > - list_init(&tracker_pt->object_list); > - list_init(&tracker_pt->tracker_list); > - > - list_add(&tracker_pt->object_list, &instance->track_head); > - list_add(&tracker_pt->tracker_list, &objdb_trackers_head); > - > - hdb_handle_put (&object_instance_database, object_handle); > - > - return (res); > -} > - > -static void object_track_stop(object_key_change_notify_fn_t key_change_notify_fn, > - object_create_notify_fn_t object_create_notify_fn, > - object_destroy_notify_fn_t object_destroy_notify_fn, > - object_reload_notify_fn_t object_reload_notify_fn, > - void * priv_data_pt) > -{ > - struct object_instance *instance; > - struct object_tracker * tracker_pt = NULL; > - struct object_tracker * obj_tracker_pt = NULL; > - struct list_head *list, *tmp_list; > - struct list_head *obj_list, *tmp_obj_list; > - int res; > - > - /* go through the global list and find all the trackers to stop */ > - for (list = objdb_trackers_head.next, tmp_list = list->next; > - list != &objdb_trackers_head; list = tmp_list, tmp_list = tmp_list->next) { > - > - tracker_pt = list_entry (list, struct object_tracker, tracker_list); > - > - if (tracker_pt && (tracker_pt->data_pt == priv_data_pt) && > - (tracker_pt->object_create_notify_fn == object_create_notify_fn) && > - (tracker_pt->object_destroy_notify_fn == object_destroy_notify_fn) && > - (tracker_pt->object_reload_notify_fn == object_reload_notify_fn) && > - (tracker_pt->key_change_notify_fn == key_change_notify_fn)) { > - > - /* get the object & take this tracker off of it's list. */ > - > - res = hdb_handle_get (&object_instance_database, > - tracker_pt->object_handle, (void *)&instance); > - if (res != 0) continue; > - > - for (obj_list = instance->track_head.next, tmp_obj_list = obj_list->next; > - obj_list != &instance->track_head; obj_list = tmp_obj_list, tmp_obj_list = tmp_obj_list->next) { > - > - obj_tracker_pt = list_entry (obj_list, struct object_tracker, object_list); > - if (obj_tracker_pt == tracker_pt) { > - /* this is the tracker we are after. */ > - list_del(obj_list); > - } > - } > - hdb_handle_put (&object_instance_database, tracker_pt->object_handle); > - > - /* remove the tracker off of the global list */ > - list_del(list); > - free(tracker_pt); > - } > - } > -} > - > -static int object_dump(hdb_handle_t object_handle, > - FILE *file) > -{ > - struct object_instance *instance; > - int res; > - > - res = hdb_handle_get (&object_instance_database, > - object_handle, (void *)&instance); > - if (res != 0) { > - return (res); > - } > - > - res = _dump_object(instance, file, -1); > - > - hdb_handle_put (&object_instance_database, object_handle); > - > - return (res); > -} > - > -static int object_write_config(const char **error_string) > -{ > - struct config_iface_ver0 **modules; > - int num_modules; > - int i; > -// int res; > - > - main_get_config_modules(&modules, &num_modules); > - > - for (i=0; i<num_modules; i++) { > - if (modules[i]->config_writeconfig) { > -/* res = modules[i]->config_writeconfig(&objdb_iface, error_string); > - if (res) { > - return res; > - }*/ > - } > - } > - return 0; > -} > - > -static int object_reload_config(int flush, const char **error_string) > -{ > - struct config_iface_ver0 **modules; > - int num_modules; > - int i; > -/* int res = 0; */ > - > - main_get_config_modules(&modules, &num_modules); > - object_reload_notification(OBJDB_RELOAD_NOTIFY_START, flush); > - > - for (i=0; i<num_modules; i++) { > - if (modules[i]->config_reloadconfig) { > -/* res = modules[i]->config_reloadconfig(&objdb_iface, flush, error_string); > - if (res) { > - object_reload_notification(OBJDB_RELOAD_NOTIFY_FAILED, flush); > - return res; > - } */ > - } > - } > - object_reload_notification(OBJDB_RELOAD_NOTIFY_END, flush); > - return 0; > -} > - > -struct objdb_iface_ver0 objdb_iface = { > - .objdb_init = objdb_init, > - .object_create = object_create, > - .object_priv_set = object_priv_set, > - .object_key_create = object_key_create, > - .object_key_delete = object_key_delete, > - .object_key_replace = object_key_replace, > - .object_destroy = object_destroy, > - .object_valid_set = object_valid_set, > - .object_key_valid_set = object_key_valid_set, > - .object_find_create = object_find_create, > - .object_find_next = object_find_next, > - .object_find_destroy = object_find_destroy, > - .object_key_get = object_key_get, > - .object_key_iter_reset = object_key_iter_reset, > - .object_key_iter = object_key_iter, > - .object_key_iter_from = object_key_iter_from, > - .object_priv_get = object_priv_get, > - .object_parent_get = object_parent_get, > - .object_name_get = object_name_get, > - .object_track_start = object_track_start, > - .object_track_stop = object_track_stop, > - .object_dump = object_dump, > - .object_write_config = object_write_config, > - .object_reload_config = object_reload_config, > - .object_key_increment = object_key_increment, > - .object_key_decrement = object_key_decrement, > - .object_key_create_typed = object_key_create_typed, > - .object_key_get_typed = object_key_get_typed, > - .object_key_iter_typed = object_key_iter_typed, > - .objdb_fini = objdb_fini, > -}; > - > -struct lcr_iface objdb_iface_ver0[1] = { > - { > - .name = "objdb", > - .version = 0, > - .versions_replace = 0, > - .versions_replace_count = 0, > - .dependencies = 0, > - .dependency_count = 0, > - .constructor = NULL, > - .destructor = NULL, > - .interfaces = NULL, > - } > -}; > - > -struct lcr_comp objdb_comp_ver0 = { > - .iface_count = 1, > - .ifaces = objdb_iface_ver0 > -}; > - > -#ifdef COROSYNC_SOLARIS > -void corosync_lcr_component_register (void); > - > -void corosync_lcr_component_register (void) { > -#else > -__attribute__ ((constructor)) static void corosync_lcr_component_register (void) { > -#endif > - lcr_interfaces_set (&objdb_iface_ver0[0], &objdb_iface); > - > - lcr_component_register (&objdb_comp_ver0); > -} > - > diff --git a/include/Makefile.am b/include/Makefile.am > index 1e6f095..5c0aab7 100644 > --- a/include/Makefile.am > +++ b/include/Makefile.am > @@ -33,14 +33,14 @@ MAINTAINERCLEANFILES = Makefile.in corosync/config.h.in > > CS_H = hdb.h cs_config.h cpg.h cfg.h evs.h mar_gen.h swab.h \ > corodefs.h \ > - confdb.h list.h corotypes.h quorum.h votequorum.h sam.h cmap.h > + list.h corotypes.h quorum.h votequorum.h sam.h cmap.h > > -CS_INTERNAL_H = ipc_cfg.h ipc_confdb.h ipc_cpg.h ipc_evs.h ipc_pload.h ipc_quorum.h \ > +CS_INTERNAL_H = ipc_cfg.h ipc_cpg.h ipc_evs.h ipc_pload.h ipc_quorum.h \ > jhash.h pload.h quorum.h sq.h ipc_votequorum.h ipc_cmap.h > > LCR_H = lcr_ckpt.h lcr_comp.h lcr_ifact.h > > -ENGINE_H = config.h coroapi.h logsys.h objdb.h quorum.h icmap.h > +ENGINE_H = config.h coroapi.h logsys.h quorum.h icmap.h > > TOTEM_H = totem.h totemip.h totempg.h > > diff --git a/include/corosync/confdb.h b/include/corosync/confdb.h > deleted file mode 100644 > index 06aac1e..0000000 > --- a/include/corosync/confdb.h > +++ /dev/null > @@ -1,353 +0,0 @@ > -/* > - * Copyright (c) 2008-2010 Red Hat, Inc. > - * > - * All rights reserved. > - * > - * Author: Christine Caulfield (ccaulfi@xxxxxxxxxx) > - * > - * 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 COROSYNC_CONFDB_H_DEFINED > -#define COROSYNC_CONFDB_H_DEFINED > - > -#include <corosync/corotypes.h> > -#include <corosync/hdb.h> > - > -#ifdef __cplusplus > -extern "C" { > -#endif > - > -/** > - * @addtogroup confdb_corosync > - * > - * @{ > - */ > -typedef uint64_t confdb_handle_t; > - > -#define OBJECT_PARENT_HANDLE 0xFFFFFFFF00000000ULL > - > -typedef enum { > - CONFDB_VALUETYPE_INT16, > - CONFDB_VALUETYPE_UINT16, > - CONFDB_VALUETYPE_INT32, > - CONFDB_VALUETYPE_UINT32, > - CONFDB_VALUETYPE_INT64, > - CONFDB_VALUETYPE_UINT64, > - CONFDB_VALUETYPE_FLOAT, > - CONFDB_VALUETYPE_DOUBLE, > - CONFDB_VALUETYPE_STRING, > - CONFDB_VALUETYPE_ANY, > -} confdb_value_types_t; > - > -typedef enum { > - CONFDB_TRACK_DEPTH_ONE, > - CONFDB_TRACK_DEPTH_RECURSIVE > -} confdb_track_depth_t; > - > -typedef enum { > - OBJECT_KEY_CREATED, > - OBJECT_KEY_REPLACED, > - OBJECT_KEY_DELETED, > -} confdb_change_type_t; > - > -typedef enum { > - CONFDB_RELOAD_NOTIFY_START, > - CONFDB_RELOAD_NOTIFY_END, > - CONFDB_RELOAD_NOTIFY_FAILED > -} confdb_reload_type_t; > - > -typedef void (*confdb_key_change_notify_fn_t) ( > - confdb_handle_t handle, > - confdb_change_type_t change_type, > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *object_name, > - size_t object_name_len, > - const void *key_name, > - size_t key_name_len, > - const void *key_value, > - size_t key_value_len); > - > -typedef void (*confdb_object_create_notify_fn_t) ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *name_pt, > - size_t name_len); > - > -typedef void (*confdb_object_delete_notify_fn_t) ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *name_pt, > - size_t name_len); > - > -typedef void (*confdb_reload_notify_fn_t) ( > - confdb_handle_t handle, > - confdb_reload_type_t type); > - > -typedef struct { > - confdb_object_create_notify_fn_t confdb_object_create_change_notify_fn; > - confdb_object_delete_notify_fn_t confdb_object_delete_change_notify_fn; > - confdb_key_change_notify_fn_t confdb_key_change_notify_fn; > - confdb_reload_notify_fn_t confdb_reload_notify_fn; > -} confdb_callbacks_t; > - > -/** @} */ > - > -/** > - * Create a new confdb connection > - */ > -cs_error_t confdb_initialize ( > - confdb_handle_t *handle, > - confdb_callbacks_t *callbacks); > - > -/** > - * Close the confdb handle > - */ > -cs_error_t confdb_finalize ( > - confdb_handle_t handle); > - > - > -/** > - * Write back the configuration > - */ > -cs_error_t confdb_write ( > - confdb_handle_t handle, > - char *error_text, > - size_t errbuf_len); > - > -/** > - * Reload the configuration > - */ > -cs_error_t confdb_reload ( > - confdb_handle_t handle, > - int flush, > - char *error_text, > - size_t errbuf_len); > - > -/** > - * Get a file descriptor on which to poll. > - * > - * confdb_handle_t is NOT a file descriptor and may not be used directly. > - */ > -cs_error_t confdb_fd_get ( > - confdb_handle_t handle, > - int *fd); > - > -/** > - * Dispatch configuration changes > - */ > -cs_error_t confdb_dispatch ( > - confdb_handle_t handle, > - cs_dispatch_flags_t dispatch_types); > - > -/** > - * Change notification > - */ > -cs_error_t confdb_track_changes ( > - confdb_handle_t handle, > - hdb_handle_t object_handle, > - unsigned int flags); > - > -cs_error_t confdb_stop_track_changes ( > - confdb_handle_t handle); > - > -/** > - * Manipulate objects > - */ > -cs_error_t confdb_object_create ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *object_name, > - size_t object_name_len, > - hdb_handle_t *object_handle); > - > -cs_error_t confdb_object_destroy ( > - confdb_handle_t handle, > - hdb_handle_t object_handle); > - > -cs_error_t confdb_object_parent_get ( > - confdb_handle_t handle, > - hdb_handle_t object_handle, > - hdb_handle_t *parent_object_handle); > - > -cs_error_t confdb_object_name_get ( > - confdb_handle_t handle, > - hdb_handle_t object_handle, > - char *object_name, > - size_t *object_name_len); > - > -/** > - * Manipulate keys > - */ > -cs_error_t confdb_key_create ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - const void *value, > - size_t value_len); > - > -cs_error_t confdb_key_create_typed ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const char *key_name, > - const void *value, > - size_t value_len, > - confdb_value_types_t type); > - > -cs_error_t confdb_key_delete ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - const void *value, > - size_t value_len); > - > -/** > - * Key queries > - */ > -cs_error_t confdb_key_get ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - void *value, > - size_t *value_len); > - > -cs_error_t confdb_key_get_typed ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const char *key_name, > - void *value, > - size_t *value_len, > - confdb_value_types_t *type); > - > -cs_error_t confdb_key_replace ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - const void *old_value, > - size_t old_value_len, > - const void *new_value, > - size_t new_value_len); > - > -cs_error_t confdb_key_increment ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - unsigned int *value); > - > -cs_error_t confdb_key_decrement ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - unsigned int *value); > - > -/** > - * Object queries > - * > - * "find" loops through all objects of a given name and is also > - * a quick way of finding a specific object, > - * > - * "iter" returns each object in sequence. > - */ > -cs_error_t confdb_object_find_start ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle); > - > -cs_error_t confdb_object_find ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *object_name, > - size_t object_name_len, > - hdb_handle_t *object_handle); > - > -cs_error_t confdb_object_find_destroy( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle); > - > -cs_error_t confdb_object_iter_start ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle); > - > -cs_error_t confdb_object_iter ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - hdb_handle_t *object_handle, > - void *object_name, > - size_t *object_name_len); > - > -cs_error_t confdb_object_iter_destroy( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle); > - > -/** > - * Key iterator > - */ > -cs_error_t confdb_key_iter_start ( > - confdb_handle_t handle, > - hdb_handle_t object_handle); > - > -cs_error_t confdb_key_iter ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - void *key_name, > - size_t *key_name_len, > - void *value, > - size_t *value_len); > - > -cs_error_t confdb_key_iter_typed ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - char *key_name, > - void *value, > - size_t *value_len, > - confdb_value_types_t *type); > - > -/** > - * Get context variable > - */ > -cs_error_t confdb_context_get ( > - confdb_handle_t handle, > - const void **context); > - > -/** > - * Set context variable > - */ > -cs_error_t confdb_context_set ( > - confdb_handle_t handle, > - const void *context); > - > -#ifdef __cplusplus > -} > -#endif > - > -#endif /* COROSYNC_CONFDB_H_DEFINED */ > diff --git a/include/corosync/corotypes.h b/include/corosync/corotypes.h > index 9f6259b..7484a94 100644 > --- a/include/corosync/corotypes.h > +++ b/include/corosync/corotypes.h > @@ -250,23 +250,6 @@ static inline cs_error_t qb_to_cs_error (int result) > #define CPG_ERR_TOO_MANY_GROUPS CS_ERR_TOO_MANY_GROUPS > #define cpg_error_t cs_error_t > > -#define CONFDB_DISPATCH_ONE CS_DISPATCH_ONE > -#define CONFDB_DISPATCH_ALL CS_DISPATCH_ALL > -#define CONFDB_DISPATCH_BLOCKING CS_DISPATCH_BLOCKING > -#define CONFDB_OK CS_OK > -#define CONFDB_ERR_LIBRARY CS_ERR_LIBRARY > -#define CONFDB_ERR_TIMEOUT CS_ERR_TIMEOUT > -#define CONFDB_ERR_TRY_AGAIN CS_ERR_TRY_AGAIN > -#define CONFDB_ERR_INVALID_PARAM CS_ERR_INVALID_PARAM > -#define CONFDB_ERR_NO_MEMORY CS_ERR_NO_MEMORY > -#define CONFDB_ERR_BAD_HANDLE CS_ERR_BAD_HANDLE > -#define CONFDB_ERR_ACCESS CS_ERR_ACCESS > -#define CONFDB_ERR_NOT_EXIST CS_ERR_NOT_EXIST > -#define CONFDB_ERR_EXIST CS_ERR_EXIST > -#define CONFDB_ERR_NOT_SUPPORTED CS_ERR_NOT_SUPPORTED > -#define CONFDB_ERR_SECURITY CS_ERR_SECURITY > -#define confdb_error_t cs_error_t > - > #define QUORUM_DISPATCH_ONE CS_DISPATCH_ONE > #define QUORUM_DISPATCH_ALL CS_DISPATCH_ALL > #define QUORUM_DISPATCH_BLOCKING CS_DISPATCH_BLOCKING > diff --git a/include/corosync/engine/coroapi.h b/include/corosync/engine/coroapi.h > index 567d14f..3849aee 100644 > --- a/include/corosync/engine/coroapi.h > +++ b/include/corosync/engine/coroapi.h > @@ -158,87 +158,6 @@ typedef enum { > } cs_fatal_error_t; > #define corosync_fatal_error_t cs_fatal_error_t; > > -#ifndef OBJECT_PARENT_HANDLE > - > -#define OBJECT_PARENT_HANDLE 0xffffffff00000000ULL > - > -struct object_valid { > - char *object_name; > - size_t object_len; > -}; > - > -struct object_key_valid { > - char *key_name; > - size_t key_len; > - int (*validate_callback) (const void *key, size_t key_len, > - const void *value, size_t value_len); > -}; > -/* deprecated */ > - > -typedef enum { > - OBJDB_VALUETYPE_INT16, > - OBJDB_VALUETYPE_UINT16, > - OBJDB_VALUETYPE_INT32, > - OBJDB_VALUETYPE_UINT32, > - OBJDB_VALUETYPE_INT64, > - OBJDB_VALUETYPE_UINT64, > - OBJDB_VALUETYPE_FLOAT, > - OBJDB_VALUETYPE_DOUBLE, > - OBJDB_VALUETYPE_STRING, > - OBJDB_VALUETYPE_ANY, > -} objdb_value_types_t; > - > -typedef enum { > - OBJECT_TRACK_DEPTH_ONE, > - OBJECT_TRACK_DEPTH_RECURSIVE > -} object_track_depth_t; > - > -typedef enum { > - OBJECT_KEY_CREATED, > - OBJECT_KEY_REPLACED, > - OBJECT_KEY_DELETED > -} object_change_type_t; > - > -typedef enum { > - OBJDB_RELOAD_NOTIFY_START, > - OBJDB_RELOAD_NOTIFY_END, > - OBJDB_RELOAD_NOTIFY_FAILED > -} objdb_reload_notify_type_t; > - > -typedef void (*object_key_change_notify_fn_t)( > - object_change_type_t change_type, > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *object_name_pt, size_t object_name_len, > - const void *key_name_pt, size_t key_len, > - const void *key_value_pt, size_t key_value_len, > - void *priv_data_pt); > - > -typedef void (*object_create_notify_fn_t) ( > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *name_pt, size_t name_len, > - void *priv_data_pt); > - > -typedef void (*object_destroy_notify_fn_t) ( > - hdb_handle_t parent_object_handle, > - const void *name_pt, size_t name_len, > - void *priv_data_pt); > - > -typedef void (*object_notify_callback_fn_t)( > - hdb_handle_t object_handle, > - const void *key_name, size_t key_len, > - const void *value, size_t value_len, > - object_change_type_t type, > - const void * priv_data_pt); > - > -typedef void (*object_reload_notify_fn_t) ( > - objdb_reload_notify_type_t, > - int flush, > - void *priv_data_pt); > - > -#endif /* OBJECT_PARENT_HANDLE_DEFINED */ > - > #ifndef QUORUM_H_DEFINED > typedef void (*quorum_callback_fn_t) (int quorate, void *context); > > @@ -259,148 +178,6 @@ typedef void (*sync_callback_fn_t) ( > > struct corosync_api_v1 { > /* > - * Object and configuration APIs > - */ > - int (*object_create) ( > - hdb_handle_t parent_object_handle, > - hdb_handle_t *object_handle, > - const void *object_name, > - size_t object_name_len); > - > - int (*object_priv_set) ( > - hdb_handle_t object_handle, > - void *priv); > - > - int (*object_key_create) ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len, > - const void *value, > - size_t value_len); > - > - int (*object_destroy) ( > - hdb_handle_t object_handle); > - > - int (*object_valid_set) ( > - hdb_handle_t object_handle, > - struct object_valid *object_valid_list, > - size_t object_valid_list_entries); > - > - int (*object_key_valid_set) ( > - hdb_handle_t object_handle, > - struct object_key_valid *object_key_valid_list, > - size_t object_key_valid_list_entries); > - > - int (*object_find_create) ( > - hdb_handle_t parent_object_handle, > - const void *object_name, > - size_t object_name_len, > - hdb_handle_t *object_find_handle); > - > - int (*object_find_next) ( > - hdb_handle_t object_find_handle, > - hdb_handle_t *object_handle); > - > - int (*object_find_destroy) ( > - hdb_handle_t object_find_handle); > - > - int (*object_key_get) ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len, > - void **value, > - size_t *value_len); > - > - int (*object_priv_get) ( > - hdb_handle_t jobject_handle, > - void **priv); > - > - int (*object_key_replace) ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len, > - const void *new_value, > - size_t new_value_len); > - > - int (*object_key_delete) ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len); > - > - int (*object_iter_reset) ( > - hdb_handle_t parent_object_handle); > - > - int (*object_iter) ( > - hdb_handle_t parent_object_handle, > - void **object_name, > - size_t *name_len, > - hdb_handle_t *object_handle); > - > - int (*object_key_iter_reset) ( > - hdb_handle_t object_handle); > - > - int (*object_key_iter) ( > - hdb_handle_t parent_object_handle, > - void **key_name, > - size_t *key_len, > - void **value, > - size_t *value_len); > - > - int (*object_parent_get) ( > - hdb_handle_t object_handle, > - hdb_handle_t *parent_handle); > - > - int (*object_name_get) ( > - hdb_handle_t object_handle, > - char *object_name, > - size_t *object_name_len); > - > - int (*object_dump) ( > - hdb_handle_t object_handle, > - FILE *file); > - > - int (*object_key_iter_from) ( > - hdb_handle_t parent_object_handle, > - hdb_handle_t start_pos, > - void **key_name, > - size_t *key_len, > - void **value, > - size_t *value_len); > - > - int (*object_track_start) ( > - hdb_handle_t object_handle, > - object_track_depth_t depth, > - object_key_change_notify_fn_t key_change_notify_fn, > - object_create_notify_fn_t object_create_notify_fn, > - object_destroy_notify_fn_t object_destroy_notify_fn, > - object_reload_notify_fn_t object_reload_notify_fn, > - void * priv_data_pt); > - > - void (*object_track_stop) ( > - object_key_change_notify_fn_t key_change_notify_fn, > - object_create_notify_fn_t object_create_notify_fn, > - object_destroy_notify_fn_t object_destroy_notify_fn, > - object_reload_notify_fn_t object_reload_notify_fn, > - void * priv_data_pt); > - > - int (*object_write_config) (const char **error_string); > - > - int (*object_reload_config) (int flush, > - const char **error_string); > - > - int (*object_key_increment) ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len, > - unsigned int *value); > - > - int (*object_key_decrement) ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len, > - unsigned int *value); > - > - /* > * Time and timer APIs > */ > int (*timer_add_duration) ( > @@ -609,27 +386,6 @@ struct corosync_api_v1 { > > qb_loop_t *(*poll_handle_get) (void); > > - int (*object_key_create_typed) ( > - hdb_handle_t object_handle, > - const char *key_name, > - const void *value, > - size_t value_len, > - objdb_value_types_t type); > - > - int (*object_key_get_typed) ( > - hdb_handle_t object_handle, > - const char *key_name, > - void **value, > - size_t *value_len, > - objdb_value_types_t *type); > - > - int (*object_key_iter_typed) ( > - hdb_handle_t parent_object_handle, > - char **key_name, > - void **value, > - size_t *value_len, > - objdb_value_types_t *type); > - > void *(*totem_get_stats)(void); > > int (*schedwrk_create_nolock) ( > diff --git a/include/corosync/engine/objdb.h b/include/corosync/engine/objdb.h > deleted file mode 100644 > index d6d46db..0000000 > --- a/include/corosync/engine/objdb.h > +++ /dev/null > @@ -1,275 +0,0 @@ > -/* > - * Copyright (c) 2006 MontaVista Software, Inc. > - * Copyright (c) 2007-2009 Red Hat, Inc. > - * > - * All rights reserved. > - * > - * Author: Steven Dake (sdake@xxxxxxxxxx) > - * > - * 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 OBJDB_H_DEFINED > -#define OBJDB_H_DEFINED > - > -#define OBJECT_PARENT_HANDLE 0xFFFFFFFF00000000ULL > - > -#include <stdio.h> > -#include <corosync/hdb.h> > - > -typedef enum { > - OBJDB_VALUETYPE_INT16, > - OBJDB_VALUETYPE_UINT16, > - OBJDB_VALUETYPE_INT32, > - OBJDB_VALUETYPE_UINT32, > - OBJDB_VALUETYPE_INT64, > - OBJDB_VALUETYPE_UINT64, > - OBJDB_VALUETYPE_FLOAT, > - OBJDB_VALUETYPE_DOUBLE, > - OBJDB_VALUETYPE_STRING, > - OBJDB_VALUETYPE_ANY, > -} objdb_value_types_t; > - > -typedef enum { > - OBJECT_TRACK_DEPTH_ONE, > - OBJECT_TRACK_DEPTH_RECURSIVE > -} object_track_depth_t; > - > -typedef enum { > - OBJECT_KEY_CREATED, > - OBJECT_KEY_REPLACED, > - OBJECT_KEY_DELETED > -} object_change_type_t; > - > -typedef enum { > - OBJDB_RELOAD_NOTIFY_START, > - OBJDB_RELOAD_NOTIFY_END, > - OBJDB_RELOAD_NOTIFY_FAILED > -} objdb_reload_notify_type_t; > - > - > -typedef void (*object_key_change_notify_fn_t)( > - object_change_type_t change_type, > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *object_name_pt, size_t object_name_len, > - const void *key_name_pt, size_t key_len, > - const void *key_value_pt, size_t key_value_len, > - void *priv_data_pt); > - > -typedef void (*object_create_notify_fn_t) (hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *name_pt, size_t name_len, > - void *priv_data_pt); > - > -typedef void (*object_destroy_notify_fn_t) (hdb_handle_t parent_object_handle, > - const void *name_pt, > - size_t name_len, > - void *priv_data_pt); > - > -typedef void (*object_reload_notify_fn_t) (objdb_reload_notify_type_t, int flush, > - void *priv_data_pt); > - > -struct object_valid { > - char *object_name; > - size_t object_len; > -}; > - > -struct object_key_valid { > - char *key_name; > - size_t key_len; > - int (*validate_callback) (const void *key, size_t key_len, > - const void *value, size_t value_len); > -}; > - > -struct objdb_iface_ver0 { > - int (*objdb_init) (void); > - > - int (*object_create) ( > - hdb_handle_t parent_object_handle, > - hdb_handle_t *object_handle, > - const void *object_name, > - size_t object_name_len); > - > - int (*object_priv_set) ( > - hdb_handle_t object_handle, > - void *priv); > - > - int (*object_key_create) ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len, > - const void *value, > - size_t value_len); > - > - int (*object_destroy) ( > - hdb_handle_t object_handle); > - > - int (*object_valid_set) ( > - hdb_handle_t object_handle, > - struct object_valid *object_valid_list, > - size_t object_valid_list_entries); > - > - int (*object_key_valid_set) ( > - hdb_handle_t object_handle, > - struct object_key_valid *object_key_valid_list, > - size_t object_key_valid_list_entries); > - > - int (*object_find_create) ( > - hdb_handle_t parent_object_handle, > - const void *object_name, > - size_t object_name_len, > - hdb_handle_t *object_find_handle); > - > - int (*object_find_next) ( > - hdb_handle_t object_find_handle, > - hdb_handle_t *object_handle); > - > - int (*object_find_destroy) ( > - hdb_handle_t object_find_handle); > - > - int (*object_key_get) ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len, > - void **value, > - size_t *value_len); > - > - int (*object_priv_get) ( > - hdb_handle_t jobject_handle, > - void **priv); > - > - int (*object_key_replace) ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len, > - const void *new_value, > - size_t new_value_len); > - > - int (*object_key_delete) ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len); > - > - int (*object_iter_reset) ( > - hdb_handle_t parent_object_handle); > - > - int (*object_iter) ( > - hdb_handle_t parent_object_handle, > - void **object_name, > - size_t *name_len, > - hdb_handle_t *object_handle); > - > - int (*object_key_iter_reset) ( > - hdb_handle_t object_handle); > - > - int (*object_key_iter) ( > - hdb_handle_t parent_object_handle, > - void **key_name, > - size_t *key_len, > - void **value, > - size_t *value_len); > - > - int (*object_parent_get) ( > - hdb_handle_t object_handle, > - hdb_handle_t *parent_handle); > - > - int (*object_name_get) ( > - hdb_handle_t object_handle, > - char *object_name, > - size_t *object_name_len); > - > - int (*object_dump) ( > - hdb_handle_t object_handle, > - FILE *file); > - > - int (*object_key_iter_from) ( > - hdb_handle_t parent_object_handle, > - hdb_handle_t start_pos, > - void **key_name, > - size_t *key_len, > - void **value, > - size_t *value_len); > - > - int (*object_track_start) ( > - hdb_handle_t object_handle, > - object_track_depth_t depth, > - object_key_change_notify_fn_t key_change_notify_fn, > - object_create_notify_fn_t object_create_notify_fn, > - object_destroy_notify_fn_t object_destroy_notify_fn, > - object_reload_notify_fn_t object_reload_notify_fn, > - void * priv_data_pt); > - > - void (*object_track_stop) ( > - object_key_change_notify_fn_t key_change_notify_fn, > - object_create_notify_fn_t object_create_notify_fn, > - object_destroy_notify_fn_t object_destroy_notify_fn, > - object_reload_notify_fn_t object_reload_notify_fn, > - void * priv_data_pt); > - > - int (*object_write_config) (const char **error_string); > - > - int (*object_reload_config) ( > - int flush, > - const char **error_string); > - > - int (*object_key_increment) ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len, > - unsigned int *value); > - > - int (*object_key_decrement) ( > - hdb_handle_t object_handle, > - const void *key_name, > - size_t key_len, > - unsigned int *value); > - > - int (*object_key_create_typed) ( > - hdb_handle_t object_handle, > - const char *key_name, > - const void *value, > - size_t value_len, > - objdb_value_types_t type); > - > - int (*object_key_get_typed) ( > - hdb_handle_t object_handle, > - const char *key_name, > - void **value, > - size_t *value_len, > - objdb_value_types_t *type); > - > - int (*object_key_iter_typed) ( > - hdb_handle_t parent_object_handle, > - char **key_name, > - void **value, > - size_t *value_len, > - objdb_value_types_t *type); > - void (*objdb_fini) (void); > -}; > - > -#endif /* OBJDB_H_DEFINED */ > diff --git a/include/corosync/ipc_confdb.h b/include/corosync/ipc_confdb.h > deleted file mode 100644 > index 760ad37..0000000 > --- a/include/corosync/ipc_confdb.h > +++ /dev/null > @@ -1,278 +0,0 @@ > -/* > - * Copyright (c) 2008-2010 Red Hat, Inc. > - * > - * All rights reserved. > - * > - * Author: Christine Caulfield (ccaulfie@xxxxxxxxxx) > - * > - * 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_CONFDB_H_DEFINED > -#define IPC_CONFDB_H_DEFINED > - > -#include <netinet/in.h> > -#include <corosync/corotypes.h> > -#include <corosync/mar_gen.h> > - > -enum req_confdb_types { > - MESSAGE_REQ_CONFDB_OBJECT_CREATE = 0, > - MESSAGE_REQ_CONFDB_OBJECT_DESTROY = 1, > - MESSAGE_REQ_CONFDB_OBJECT_FIND = 2, > - MESSAGE_REQ_CONFDB_KEY_CREATE = 3, > - MESSAGE_REQ_CONFDB_KEY_GET = 4, > - MESSAGE_REQ_CONFDB_KEY_REPLACE = 5, > - MESSAGE_REQ_CONFDB_KEY_DELETE = 6, > - MESSAGE_REQ_CONFDB_OBJECT_ITER = 7, > - MESSAGE_REQ_CONFDB_OBJECT_PARENT_GET = 8, > - MESSAGE_REQ_CONFDB_KEY_ITER = 9, > - MESSAGE_REQ_CONFDB_TRACK_START = 10, > - MESSAGE_REQ_CONFDB_TRACK_STOP = 11, > - MESSAGE_REQ_CONFDB_WRITE = 12, > - MESSAGE_REQ_CONFDB_RELOAD = 13, > - MESSAGE_REQ_CONFDB_OBJECT_FIND_DESTROY = 14, > - MESSAGE_REQ_CONFDB_KEY_INCREMENT = 15, > - MESSAGE_REQ_CONFDB_KEY_DECREMENT = 16, > - MESSAGE_REQ_CONFDB_KEY_CREATE_TYPED = 17, > - MESSAGE_REQ_CONFDB_KEY_GET_TYPED = 18, > - MESSAGE_REQ_CONFDB_KEY_ITER_TYPED = 19, > - MESSAGE_REQ_CONFDB_OBJECT_NAME_GET = 20, > -}; > - > -enum res_confdb_types { > - MESSAGE_RES_CONFDB_OBJECT_CREATE = 0, > - MESSAGE_RES_CONFDB_OBJECT_DESTROY = 1, > - MESSAGE_RES_CONFDB_OBJECT_FIND = 2, > - MESSAGE_RES_CONFDB_KEY_CREATE = 3, > - MESSAGE_RES_CONFDB_KEY_GET = 4, > - MESSAGE_RES_CONFDB_KEY_REPLACE = 5, > - MESSAGE_RES_CONFDB_KEY_DELETE = 6, > - MESSAGE_RES_CONFDB_OBJECT_ITER = 7, > - MESSAGE_RES_CONFDB_OBJECT_PARENT_GET = 8, > - MESSAGE_RES_CONFDB_KEY_ITER = 9, > - MESSAGE_RES_CONFDB_TRACK_START = 10, > - MESSAGE_RES_CONFDB_TRACK_STOP = 11, > - MESSAGE_RES_CONFDB_KEY_CHANGE_CALLBACK = 12, > - MESSAGE_RES_CONFDB_OBJECT_CREATE_CALLBACK = 13, > - MESSAGE_RES_CONFDB_OBJECT_DESTROY_CALLBACK = 14, > - MESSAGE_RES_CONFDB_WRITE = 15, > - MESSAGE_RES_CONFDB_RELOAD = 16, > - MESSAGE_RES_CONFDB_OBJECT_FIND_DESTROY = 17, > - MESSAGE_RES_CONFDB_KEY_INCREMENT = 18, > - MESSAGE_RES_CONFDB_KEY_DECREMENT = 19, > - MESSAGE_RES_CONFDB_KEY_GET_TYPED = 20, > - MESSAGE_RES_CONFDB_KEY_ITER_TYPED = 21, > - MESSAGE_RES_CONFDB_RELOAD_CALLBACK = 22, > - MESSAGE_RES_CONFDB_OBJECT_NAME_GET = 23, > -}; > - > - > -struct req_lib_confdb_object_create { > - struct qb_ipc_request_header header __attribute__((aligned(8))); > - mar_uint64_t parent_object_handle __attribute__((aligned(8))); > - mar_name_t object_name __attribute__((aligned(8))); > -}; > - > -struct res_lib_confdb_object_create { > - struct qb_ipc_response_header header __attribute__((aligned(8))); > - mar_uint64_t object_handle __attribute__((aligned(8))); > -}; > - > -struct req_lib_confdb_object_destroy { > - struct qb_ipc_request_header header __attribute__((aligned(8))); > - mar_uint64_t object_handle __attribute__((aligned(8))); > -}; > - > -struct req_lib_confdb_object_parent_get { > - struct qb_ipc_request_header header __attribute__((aligned(8))); > - mar_uint64_t object_handle __attribute__((aligned(8))); > -}; > - > -struct res_lib_confdb_object_parent_get { > - struct qb_ipc_response_header header __attribute__((aligned(8))); > - mar_uint64_t parent_object_handle __attribute__((aligned(8))); > -}; > - > -struct req_lib_confdb_object_name_get { > - struct qb_ipc_request_header header __attribute__((aligned(8))); > - mar_uint64_t object_handle __attribute__((aligned(8))); > -}; > - > -struct res_lib_confdb_object_name_get { > - struct qb_ipc_response_header header __attribute__((aligned(8))); > - mar_name_t object_name __attribute__((aligned(8))); > -}; > - > -struct req_lib_confdb_key_create { > - struct qb_ipc_request_header header __attribute__((aligned(8))); > - mar_uint64_t object_handle __attribute__((aligned(8))); > - mar_name_t key_name __attribute__((aligned(8))); > - mar_name_t value __attribute__((aligned(8))); > -}; > - > -struct req_lib_confdb_key_create_typed { > - struct qb_ipc_request_header header __attribute__((aligned(8))); > - mar_uint64_t object_handle __attribute__((aligned(8))); > - mar_name_t key_name __attribute__((aligned(8))); > - mar_name_t value __attribute__((aligned(8))); > - mar_int32_t type __attribute__((aligned(8))); > -}; > - > -struct req_lib_confdb_key_delete { > - struct qb_ipc_request_header header __attribute__((aligned(8))); > - mar_uint64_t object_handle __attribute__((aligned(8))); > - mar_name_t key_name __attribute__((aligned(8))); > - mar_name_t value __attribute__((aligned(8))); > -}; > - > -struct req_lib_confdb_key_replace { > - struct qb_ipc_request_header header __attribute__((aligned(8))); > - mar_uint64_t object_handle __attribute__((aligned(8))); > - mar_name_t key_name __attribute__((aligned(8))); > - mar_name_t old_value __attribute__((aligned(8))); > - mar_name_t new_value __attribute__((aligned(8))); > -}; > - > -struct req_lib_confdb_object_find { > - struct qb_ipc_request_header header __attribute__((aligned(8))); > - mar_uint64_t parent_object_handle __attribute__((aligned(8))); > - mar_name_t object_name __attribute__((aligned(8))); > - mar_uint64_t find_handle __attribute__((aligned(8))); > -}; > - > -struct res_lib_confdb_object_find { > - struct qb_ipc_response_header header __attribute__((aligned(8))); > - mar_uint64_t object_handle __attribute__((aligned(8))); > - mar_uint64_t find_handle __attribute__((aligned(8))); > -}; > - > -struct req_lib_confdb_object_iter { > - struct qb_ipc_request_header header __attribute__((aligned(8))); > - mar_uint64_t parent_object_handle __attribute__((aligned(8))); > - mar_uint64_t find_handle __attribute__((aligned(8))); > -}; > - > -struct res_lib_confdb_object_iter { > - struct qb_ipc_response_header header __attribute__((aligned(8))); > - mar_name_t object_name __attribute__((aligned(8))); > - mar_uint64_t object_handle __attribute__((aligned(8))); > - mar_uint64_t find_handle __attribute__((aligned(8))); > -}; > - > -struct req_lib_confdb_key_iter { > - struct qb_ipc_request_header header __attribute__((aligned(8))); > - mar_uint64_t parent_object_handle __attribute__((aligned(8))); > - mar_uint64_t next_entry __attribute__((aligned(8))); > -}; > - > -struct res_lib_confdb_key_iter { > - struct qb_ipc_response_header header __attribute__((aligned(8))); > - mar_name_t key_name __attribute__((aligned(8))); > - mar_name_t value __attribute__((aligned(8))); > -}; > -struct res_lib_confdb_key_iter_typed { > - struct qb_ipc_response_header header __attribute__((aligned(8))); > - mar_name_t key_name __attribute__((aligned(8))); > - mar_name_t value __attribute__((aligned(8))); > - mar_int32_t type __attribute__((aligned(8))); > -}; > - > -struct req_lib_confdb_key_get { > - struct qb_ipc_request_header header __attribute__((aligned(8))); > - mar_uint64_t parent_object_handle __attribute__((aligned(8))); > - mar_name_t key_name __attribute__((aligned(8))); > -}; > - > -struct req_lib_confdb_object_find_destroy { > - struct qb_ipc_request_header header __attribute__((aligned(8))); > - mar_uint64_t find_handle __attribute__((aligned(8))); > -}; > - > -struct res_lib_confdb_key_get { > - struct qb_ipc_response_header header __attribute__((aligned(8))); > - mar_name_t value __attribute__((aligned(8))); > -}; > -struct res_lib_confdb_key_get_typed { > - struct qb_ipc_response_header header __attribute__((aligned(8))); > - mar_name_t value __attribute__((aligned(8))); > - mar_int32_t type __attribute__((aligned(8))); > -}; > - > -struct res_lib_confdb_key_incdec { > - struct qb_ipc_response_header header __attribute__((aligned(8))); > - mar_uint32_t value __attribute__((aligned(8))); > -}; > - > -struct res_lib_confdb_write { > - struct qb_ipc_response_header header __attribute__((aligned(8))); > - mar_name_t error __attribute__((aligned(8))); > -}; > - > -struct req_lib_confdb_reload { > - struct qb_ipc_response_header header __attribute__((aligned(8))); > - mar_int32_t flush __attribute__((aligned(8))); > -}; > - > -struct res_lib_confdb_reload { > - struct qb_ipc_response_header header __attribute__((aligned(8))); > - mar_name_t error __attribute__((aligned(8))); > -}; > - > -struct res_lib_confdb_key_change_callback { > - struct qb_ipc_response_header header __attribute__((aligned(8))); > - mar_uint64_t change_type __attribute__((aligned(8))); > - mar_uint64_t parent_object_handle __attribute__((aligned(8))); > - mar_uint64_t object_handle __attribute__((aligned(8))); > - mar_name_t object_name __attribute__((aligned(8))); > - mar_name_t key_name __attribute__((aligned(8))); > - mar_name_t key_value __attribute__((aligned(8))); > -}; > - > -struct res_lib_confdb_object_create_callback { > - struct qb_ipc_response_header header __attribute__((aligned(8))); > - mar_uint64_t parent_object_handle __attribute__((aligned(8))); > - mar_uint64_t object_handle __attribute__((aligned(8))); > - mar_name_t name __attribute__((aligned(8))); > -}; > - > -struct res_lib_confdb_object_destroy_callback { > - struct qb_ipc_response_header header __attribute__((aligned(8))); > - mar_uint64_t parent_object_handle __attribute__((aligned(8))); > - mar_name_t name __attribute__((aligned(8))); > -}; > - > -struct res_lib_confdb_reload_callback { > - struct qb_ipc_response_header header __attribute__((aligned(8))); > - mar_uint32_t type __attribute__((aligned(8))); > -}; > - > -struct req_lib_confdb_object_track_start { > - struct qb_ipc_request_header header __attribute__((aligned(8))); > - mar_uint64_t object_handle __attribute__((aligned(8))); > - mar_uint32_t flags __attribute__((aligned(8))); > -}; > - > -#endif /* IPC_CONFDB_H_DEFINED */ > diff --git a/include/corosync/totem/totem.h b/include/corosync/totem/totem.h > index 2166143..4cfc753 100644 > --- a/include/corosync/totem/totem.h > +++ b/include/corosync/totem/totem.h > @@ -204,7 +204,6 @@ struct memb_ring_id { > } __attribute__((packed)); > > typedef struct { > - hdb_handle_t handle; > int is_dirty; > time_t last_updated; > } totem_stats_header_t; > diff --git a/lib/Makefile.am b/lib/Makefile.am > index b97a3b5..0262453 100644 > --- a/lib/Makefile.am > +++ b/lib/Makefile.am > @@ -46,7 +46,7 @@ AM_LDFLAGS = -lpthread > > INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include > > -lib_LIBRARIES = libcpg.a libconfdb.a libquorum.a libevs.a libcfg.a \ > +lib_LIBRARIES = libcpg.a libquorum.a libevs.a libcfg.a \ > libvotequorum.a libpload.a libsam.a libcmap.a > SHARED_LIBS_SO = $(lib_LIBRARIES:%.a=%.so) > > @@ -56,15 +56,12 @@ libevs_a_SOURCES = evs.c > libpload_a_SOURCES = pload.c > libquorum_a_SOURCES = quorum.c > libvotequorum_a_SOURCES = votequorum.c > -libcmap_a_SOURCES = cmap.c > -libconfdb_a_SOURCES = confdb.c sa-confdb.c > -libconfdb_a_LIBADD = ../lcr/lcr_ifact.o > -CONFDB_LINKER_ADD = $(OS_DYFLAGS) $(OS_LDL) > -SAM_LINKER_ADD = -L. -lquorum -lconfdb > +libcmap_a_SOURCES = cmap.c > +SAM_LINKER_ADD = -L. -lquorum -lcmap > libsam_a_SOURCES = sam.c > > -noinst_HEADERS = sa-confdb.h util.h \ > - libcfg.versions libconfdb.versions \ > +noinst_HEADERS = util.h \ > + libcfg.versions \ > libcpg.versions \ > libevs.versions libpload.versions \ > libquorum.versions libvotequorum.versions \ > diff --git a/lib/confdb.c b/lib/confdb.c > deleted file mode 100644 > index 831b5cc..0000000 > --- a/lib/confdb.c > +++ /dev/null > @@ -1,1814 +0,0 @@ > -/* > - * Copyright (c) 2008-2010 Red Hat, Inc. > - * > - * All rights reserved. > - * > - * Author: Christine Caulfield (ccaulfie@xxxxxxxxxx) > - * > - * 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. > - */ > -/* > - * Provides access to data in the corosync object database > - */ > - > -#include <config.h> > - > -#include <stdlib.h> > -#include <string.h> > -#include <unistd.h> > -#include <pthread.h> > -#include <sys/types.h> > -#include <errno.h> > - > -#include <corosync/corotypes.h> > -#include <corosync/corodefs.h> > -#include <corosync/hdb.h> > -#include <corosync/list.h> > -#include <qb/qbipcc.h> > - > -#include <corosync/confdb.h> > -#include <corosync/ipc_confdb.h> > - > -#include "util.h" > - > -#include "sa-confdb.h" > - > -/* Hold the information for iterators so that > - callers can do recursive tree traversals. > - each object_handle can have its own iterator */ > -struct iter_context { > - struct list_head list; > - hdb_handle_t parent_object_handle; > - hdb_handle_t find_handle; > - hdb_handle_t next_entry; > -}; > - > -struct confdb_inst { > - qb_ipcc_connection_t *c; > - int finalize; > - int standalone; > - confdb_callbacks_t callbacks; > - const void *context; > - > - struct list_head object_find_head; > - struct list_head object_iter_head; > - struct list_head key_iter_head; > -}; > - > -DECLARE_HDB_DATABASE(confdb_handle_t_db,NULL); > - > -static cs_error_t do_find_destroy(struct confdb_inst *confdb_inst, hdb_handle_t find_handle); > - > - > -/* Safely tidy one iterator context list */ > -static void free_context_list(struct confdb_inst *confdb_inst, struct list_head *list) > -{ > - struct iter_context *context; > - struct list_head *iter, *tmp; > - > - for (iter = list->next, tmp = iter->next; > - iter != list; iter = tmp, tmp = iter->next) { > - > - context = list_entry (iter, struct iter_context, list); > - (void)do_find_destroy(confdb_inst, context->find_handle); > - free(context); > - } > -} > - > -static struct iter_context *find_iter_context(struct list_head *list, hdb_handle_t object_handle) > -{ > - struct iter_context *context; > - struct list_head *iter; > - > - for (iter = list->next; > - iter != list; iter = iter->next) { > - > - context = list_entry (iter, struct iter_context, list); > - if (context->parent_object_handle == object_handle) > - return context; > - } > - return NULL; > -} > - > -/** > - * @defgroup confdb_corosync confdb > - * @ingroup corosync > - * > - * @{ > - */ > - > -cs_error_t confdb_initialize ( > - confdb_handle_t *handle, > - confdb_callbacks_t *callbacks) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - > - error = hdb_error_to_cs(hdb_handle_create (&confdb_handle_t_db, sizeof (struct confdb_inst), handle)); > - if (error != CS_OK) { > - goto error_no_destroy; > - } > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, *handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - goto error_destroy; > - } > - > - if (getenv("COROSYNC_DEFAULT_CONFIG_IFACE")) { > - error = confdb_sa_init(); > - confdb_inst->standalone = 1; > - } > - else { > - error = CS_OK; > - confdb_inst->c = qb_ipcc_connect ("confdb", IPC_REQUEST_SIZE); > - if (confdb_inst->c == NULL) { > - error = qb_to_cs_error(-errno); > - goto error_put_destroy; > - } > - } > - if (error != CS_OK) > - goto error_put_destroy; > - > - if (callbacks) { > - memcpy (&confdb_inst->callbacks, callbacks, sizeof (confdb_callbacks_t)); > - } > - > - list_init (&confdb_inst->object_find_head); > - list_init (&confdb_inst->object_iter_head); > - list_init (&confdb_inst->key_iter_head); > - > - (void)hdb_handle_put (&confdb_handle_t_db, *handle); > - > - return (CS_OK); > - > -error_put_destroy: > - (void)hdb_handle_put (&confdb_handle_t_db, *handle); > -error_destroy: > - (void)hdb_handle_destroy (&confdb_handle_t_db, *handle); > -error_no_destroy: > - return (error); > -} > - > -cs_error_t confdb_finalize ( > - confdb_handle_t handle) > -{ > - struct confdb_inst *confdb_inst; > - cs_error_t error; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - /* > - * Another thread has already started finalizing > - */ > - if (confdb_inst->finalize) { > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - return (CS_ERR_BAD_HANDLE); > - } > - > - confdb_inst->finalize = 1; > - > - /* Free saved context handles */ > - free_context_list(confdb_inst, &confdb_inst->object_find_head); > - free_context_list(confdb_inst, &confdb_inst->object_iter_head); > - free_context_list(confdb_inst, &confdb_inst->key_iter_head); > - > - if (!confdb_inst->standalone) { > - qb_ipcc_disconnect (confdb_inst->c); > - } > - > - (void)hdb_handle_destroy (&confdb_handle_t_db, handle); > - > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (CS_OK); > -} > - > -cs_error_t confdb_fd_get ( > - confdb_handle_t handle, > - int *fd) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - error = qb_to_cs_error (qb_ipcc_fd_get (confdb_inst->c, fd)); > - > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > -cs_error_t confdb_context_get ( > - confdb_handle_t handle, > - const void **context) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - *context = confdb_inst->context; > - > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (CS_OK); > -} > - > -cs_error_t confdb_context_set ( > - confdb_handle_t handle, > - const void *context) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - confdb_inst->context = context; > - > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (CS_OK); > -} > - > -cs_error_t confdb_dispatch ( > - confdb_handle_t handle, > - cs_dispatch_flags_t dispatch_types) > -{ > - int timeout = -1; > - cs_error_t error; > - int cont = 1; /* always continue do loop except when set to 0 */ > - struct confdb_inst *confdb_inst; > - confdb_callbacks_t callbacks; > - struct res_lib_confdb_key_change_callback *res_key_changed_pt; > - struct res_lib_confdb_object_create_callback *res_object_created_pt; > - struct res_lib_confdb_object_destroy_callback *res_object_destroyed_pt; > - struct res_lib_confdb_reload_callback *res_reload_pt; > - struct qb_ipc_response_header *dispatch_data; > - char dispatch_buf[IPC_DISPATCH_SIZE]; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - if (confdb_inst->standalone) { > - error = CS_ERR_NOT_SUPPORTED; > - goto error_put; > - } > - > - /* > - * Timeout instantly for CS_DISPATCH_ONE or CS_DISPATCH_ALL and > - * wait indefinitely for CS_DISPATCH_BLOCKING > - */ > - if (dispatch_types == CONFDB_DISPATCH_ALL) { > - timeout = 0; > - } > - > - dispatch_data = (struct qb_ipc_response_header *)dispatch_buf; > - do { > - error = qb_to_cs_error(qb_ipcc_event_recv ( > - confdb_inst->c, > - dispatch_buf, > - IPC_DISPATCH_SIZE, > - timeout)); > - if (error == CS_ERR_BAD_HANDLE) { > - error = CS_OK; > - goto error_put; > - } > - if (error == CS_ERR_TRY_AGAIN) { > - error = CS_OK; > - if (dispatch_types == CONFDB_DISPATCH_ALL) { > - break; /* exit do while cont is 1 loop */ > - } else { > - continue; /* next poll */ > - } > - } > - if (error != CS_OK) { > - goto error_put; > - } > - > - > - /* > - * Make copy of callbacks, message data, unlock instance, and call callback > - * A risk of this dispatch method is that the callback routines may > - * operate at the same time that confdbFinalize has been called. > - */ > - memcpy (&callbacks, &confdb_inst->callbacks, sizeof (confdb_callbacks_t)); > - > - > - /* > - * Dispatch incoming message > - */ > - switch (dispatch_data->id) { > - case MESSAGE_RES_CONFDB_KEY_CHANGE_CALLBACK: > - if (callbacks.confdb_key_change_notify_fn == NULL) { > - break; > - } > - > - res_key_changed_pt = (struct res_lib_confdb_key_change_callback *)dispatch_data; > - > - callbacks.confdb_key_change_notify_fn(handle, > - res_key_changed_pt->change_type, > - res_key_changed_pt->object_handle, > - res_key_changed_pt->parent_object_handle, > - res_key_changed_pt->object_name.value, > - res_key_changed_pt->object_name.length, > - res_key_changed_pt->key_name.value, > - res_key_changed_pt->key_name.length, > - res_key_changed_pt->key_value.value, > - res_key_changed_pt->key_value.length); > - break; > - > - case MESSAGE_RES_CONFDB_OBJECT_CREATE_CALLBACK: > - if (callbacks.confdb_object_create_change_notify_fn == NULL) { > - break; > - } > - > - res_object_created_pt = (struct res_lib_confdb_object_create_callback *)dispatch_data; > - > - callbacks.confdb_object_create_change_notify_fn(handle, > - res_object_created_pt->object_handle, > - res_object_created_pt->parent_object_handle, > - res_object_created_pt->name.value, > - res_object_created_pt->name.length); > - break; > - > - case MESSAGE_RES_CONFDB_OBJECT_DESTROY_CALLBACK: > - if (callbacks.confdb_object_delete_change_notify_fn == NULL) { > - break; > - } > - > - res_object_destroyed_pt = (struct res_lib_confdb_object_destroy_callback *)dispatch_data; > - > - callbacks.confdb_object_delete_change_notify_fn(handle, > - res_object_destroyed_pt->parent_object_handle, > - res_object_destroyed_pt->name.value, > - res_object_destroyed_pt->name.length); > - break; > - > - case MESSAGE_RES_CONFDB_RELOAD_CALLBACK: > - if (callbacks.confdb_reload_notify_fn == NULL) { > - break; > - } > - > - res_reload_pt = (struct res_lib_confdb_reload_callback *)dispatch_data; > - > - callbacks.confdb_reload_notify_fn(handle, > - res_reload_pt->type); > - break; > - > - default: > - error = CS_ERR_LIBRARY; > - goto error_noput; > - break; > - } > - > - /* > - * Determine if more messages should be processed > - */ > - if (dispatch_types == CS_DISPATCH_ONE) { > - cont = 0; > - } > - } while (cont); > - > -error_put: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > -error_noput: > - return (error); > -} > - > -cs_error_t confdb_object_create ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *object_name, > - size_t object_name_len, > - hdb_handle_t *object_handle) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct req_lib_confdb_object_create req_lib_confdb_object_create; > - struct res_lib_confdb_object_create res_lib_confdb_object_create; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_object_create(parent_object_handle, > - object_name, object_name_len, > - object_handle)) > - error = CS_ERR_ACCESS; > - goto error_exit; > - } > - > - req_lib_confdb_object_create.header.size = sizeof (struct req_lib_confdb_object_create); > - req_lib_confdb_object_create.header.id = MESSAGE_REQ_CONFDB_OBJECT_CREATE; > - req_lib_confdb_object_create.parent_object_handle = parent_object_handle; > - memcpy(req_lib_confdb_object_create.object_name.value, object_name, object_name_len); > - req_lib_confdb_object_create.object_name.length = object_name_len; > - > - iov.iov_base = (char *)&req_lib_confdb_object_create; > - iov.iov_len = sizeof (struct req_lib_confdb_object_create); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res_lib_confdb_object_create, > - sizeof (struct res_lib_confdb_object_create), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = res_lib_confdb_object_create.header.error; > - *object_handle = res_lib_confdb_object_create.object_handle; > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > -cs_error_t confdb_object_destroy ( > - confdb_handle_t handle, > - hdb_handle_t object_handle) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct req_lib_confdb_object_destroy req_lib_confdb_object_destroy; > - struct qb_ipc_response_header res; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_object_destroy(object_handle)) > - error = CS_ERR_ACCESS; > - goto error_exit; > - } > - > - req_lib_confdb_object_destroy.header.size = sizeof (struct req_lib_confdb_object_destroy); > - req_lib_confdb_object_destroy.header.id = MESSAGE_REQ_CONFDB_OBJECT_DESTROY; > - req_lib_confdb_object_destroy.object_handle = object_handle; > - > - iov.iov_base = (char *)&req_lib_confdb_object_destroy; > - iov.iov_len = sizeof (struct req_lib_confdb_object_destroy); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res, > - sizeof (struct qb_ipc_response_header), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = res.error; > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > -cs_error_t confdb_object_parent_get ( > - confdb_handle_t handle, > - hdb_handle_t object_handle, > - hdb_handle_t *parent_object_handle) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct req_lib_confdb_object_parent_get req_lib_confdb_object_parent_get; > - struct res_lib_confdb_object_parent_get res_lib_confdb_object_parent_get; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_object_parent_get(object_handle, parent_object_handle)) > - error = CS_ERR_ACCESS; > - goto error_exit; > - } > - > - req_lib_confdb_object_parent_get.header.size = sizeof (struct req_lib_confdb_object_parent_get); > - req_lib_confdb_object_parent_get.header.id = MESSAGE_REQ_CONFDB_OBJECT_PARENT_GET; > - req_lib_confdb_object_parent_get.object_handle = object_handle; > - > - iov.iov_base = (char *)&req_lib_confdb_object_parent_get; > - iov.iov_len = sizeof (struct req_lib_confdb_object_parent_get); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res_lib_confdb_object_parent_get, > - sizeof (struct res_lib_confdb_object_parent_get), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = res_lib_confdb_object_parent_get.header.error; > - *parent_object_handle = res_lib_confdb_object_parent_get.parent_object_handle; > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > -cs_error_t confdb_object_name_get ( > - confdb_handle_t handle, > - hdb_handle_t object_handle, > - char *object_name, > - size_t *object_name_len) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct req_lib_confdb_object_name_get request; > - struct res_lib_confdb_object_name_get response; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_object_name_get(object_handle, object_name, object_name_len)) > - error = CS_ERR_ACCESS; > - goto error_exit; > - } > - > - request.header.size = sizeof (struct req_lib_confdb_object_name_get); > - request.header.id = MESSAGE_REQ_CONFDB_OBJECT_NAME_GET; > - request.object_handle = object_handle; > - > - iov.iov_base = (char *)&request; > - iov.iov_len = sizeof (struct req_lib_confdb_object_name_get); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &response, > - sizeof (struct res_lib_confdb_object_name_get), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = response.header.error; > - if (error == CS_OK) { > - *object_name_len = response.object_name.length; > - memcpy(object_name, response.object_name.value, *object_name_len); > - } > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > -static cs_error_t do_find_destroy( > - struct confdb_inst *confdb_inst, > - hdb_handle_t find_handle) > -{ > - cs_error_t error; > - struct iovec iov; > - struct req_lib_confdb_object_find_destroy req_lib_confdb_object_find_destroy; > - struct qb_ipc_response_header res; > - > - if (!find_handle) > - return CS_OK; > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_find_destroy(find_handle)) > - error = CS_ERR_ACCESS; > - goto error_exit; > - } > - > - req_lib_confdb_object_find_destroy.header.size = sizeof (struct req_lib_confdb_object_find_destroy); > - req_lib_confdb_object_find_destroy.header.id = MESSAGE_REQ_CONFDB_OBJECT_FIND_DESTROY; > - req_lib_confdb_object_find_destroy.find_handle = find_handle; > - > - iov.iov_base = (char *)&req_lib_confdb_object_find_destroy; > - iov.iov_len = sizeof (struct req_lib_confdb_object_find_destroy); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res, > - sizeof (struct qb_ipc_response_header), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = res.error; > - > -error_exit: > - > - return (error); > -} > - > -cs_error_t confdb_object_find_destroy( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle) > -{ > - struct iter_context *context; > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - context = find_iter_context(&confdb_inst->object_find_head, parent_object_handle); > - error = do_find_destroy(confdb_inst, context->find_handle); > - if (error == CS_OK) { > - list_del(&context->list); > - free(context); > - } > - > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - return error; > -} > - > -cs_error_t confdb_object_iter_destroy( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle) > -{ > - struct iter_context *context; > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - context = find_iter_context(&confdb_inst->object_iter_head, parent_object_handle); > - error = do_find_destroy(confdb_inst, context->find_handle); > - if (error == CS_OK) { > - list_del(&context->list); > - free(context); > - } > - > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - return error; > -} > - > - > -cs_error_t confdb_key_create ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - const void *value, > - size_t value_len) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct req_lib_confdb_key_create req_lib_confdb_key_create; > - struct qb_ipc_response_header res; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_key_create(parent_object_handle, > - key_name, key_name_len, > - value, value_len)) > - error = CS_ERR_ACCESS; > - goto error_exit; > - } > - > - req_lib_confdb_key_create.header.size = sizeof (struct req_lib_confdb_key_create); > - req_lib_confdb_key_create.header.id = MESSAGE_REQ_CONFDB_KEY_CREATE; > - req_lib_confdb_key_create.object_handle = parent_object_handle; > - memcpy(req_lib_confdb_key_create.key_name.value, key_name, key_name_len); > - req_lib_confdb_key_create.key_name.length = key_name_len; > - memcpy(req_lib_confdb_key_create.value.value, value, value_len); > - req_lib_confdb_key_create.value.length = value_len; > - > - iov.iov_base = (char *)&req_lib_confdb_key_create; > - iov.iov_len = sizeof (struct req_lib_confdb_key_create); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res, > - sizeof (res), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = res.error; > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > - > -cs_error_t confdb_key_create_typed ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const char *key_name, > - const void *value, > - size_t value_len, > - confdb_value_types_t type) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct req_lib_confdb_key_create_typed request; > - struct qb_ipc_response_header res; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_key_create_typed(parent_object_handle, > - key_name, value, value_len, type)) > - error = CS_ERR_ACCESS; > - goto error_exit; > - } > - > - request.header.size = sizeof (struct req_lib_confdb_key_create_typed); > - request.header.id = MESSAGE_REQ_CONFDB_KEY_CREATE_TYPED; > - request.object_handle = parent_object_handle; > - request.key_name.length = strlen(key_name)+1; > - memcpy(request.key_name.value, key_name, request.key_name.length); > - memcpy(request.value.value, value, value_len); > - request.value.length = value_len; > - request.type = type; > - > - iov.iov_base = (char *)&request; > - iov.iov_len = sizeof (struct req_lib_confdb_key_create_typed); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res, > - sizeof (res), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = res.error; > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > - > - > -cs_error_t confdb_key_delete ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - const void *value, > - size_t value_len) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct req_lib_confdb_key_delete req_lib_confdb_key_delete; > - struct qb_ipc_response_header res; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_key_delete(parent_object_handle, > - key_name, key_name_len, > - value, value_len)) > - error = CS_ERR_ACCESS; > - goto error_exit; > - } > - > - req_lib_confdb_key_delete.header.size = sizeof (struct req_lib_confdb_key_delete); > - req_lib_confdb_key_delete.header.id = MESSAGE_REQ_CONFDB_KEY_DELETE; > - req_lib_confdb_key_delete.object_handle = parent_object_handle; > - memcpy(req_lib_confdb_key_delete.key_name.value, key_name, key_name_len); > - req_lib_confdb_key_delete.key_name.length = key_name_len; > - memcpy(req_lib_confdb_key_delete.value.value, value, value_len); > - req_lib_confdb_key_delete.value.length = value_len; > - > - iov.iov_base = (char *)&req_lib_confdb_key_delete; > - iov.iov_len = sizeof (struct req_lib_confdb_key_delete); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res, > - sizeof (res), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = res.error; > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > -cs_error_t confdb_key_get ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - void *value, > - size_t *value_len) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct req_lib_confdb_key_get req_lib_confdb_key_get; > - struct res_lib_confdb_key_get res_lib_confdb_key_get; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_key_get(parent_object_handle, > - key_name, key_name_len, > - value, value_len)) > - error = CS_ERR_ACCESS; > - goto error_exit; > - } > - > - req_lib_confdb_key_get.header.size = sizeof (struct req_lib_confdb_key_get); > - req_lib_confdb_key_get.header.id = MESSAGE_REQ_CONFDB_KEY_GET; > - req_lib_confdb_key_get.parent_object_handle = parent_object_handle; > - memcpy(req_lib_confdb_key_get.key_name.value, key_name, key_name_len); > - req_lib_confdb_key_get.key_name.length = key_name_len; > - > - iov.iov_base = (char *)&req_lib_confdb_key_get; > - iov.iov_len = sizeof (struct req_lib_confdb_key_get); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res_lib_confdb_key_get, > - sizeof (struct res_lib_confdb_key_get), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = res_lib_confdb_key_get.header.error; > - if (error == CS_OK) { > - *value_len = res_lib_confdb_key_get.value.length; > - memcpy(value, res_lib_confdb_key_get.value.value, *value_len); > - } > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > - > -cs_error_t confdb_key_get_typed ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const char *key_name, > - void *value, > - size_t *value_len, > - confdb_value_types_t *type) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct req_lib_confdb_key_get req_lib_confdb_key_get; > - struct res_lib_confdb_key_get_typed response; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_key_get_typed(parent_object_handle, > - key_name, value, value_len, (int*)type)) > - error = CS_ERR_ACCESS; > - goto error_exit; > - } > - > - req_lib_confdb_key_get.header.size = sizeof (struct req_lib_confdb_key_get); > - req_lib_confdb_key_get.header.id = MESSAGE_REQ_CONFDB_KEY_GET_TYPED; > - req_lib_confdb_key_get.parent_object_handle = parent_object_handle; > - req_lib_confdb_key_get.key_name.length = strlen(key_name) + 1; > - memcpy(req_lib_confdb_key_get.key_name.value, key_name, req_lib_confdb_key_get.key_name.length); > - > - iov.iov_base = (char *)&req_lib_confdb_key_get; > - iov.iov_len = sizeof (struct req_lib_confdb_key_get); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &response, > - sizeof (struct res_lib_confdb_key_get_typed), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = response.header.error; > - if (error == CS_OK) { > - *value_len = response.value.length; > - *type = response.type; > - memcpy(value, response.value.value, *value_len); > - } > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > - > -cs_error_t confdb_key_increment ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - unsigned int *value) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct req_lib_confdb_key_get req_lib_confdb_key_get; > - struct res_lib_confdb_key_incdec res_lib_confdb_key_incdec; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_key_increment(parent_object_handle, > - key_name, key_name_len, > - value)) > - error = CS_ERR_ACCESS; > - goto error_exit; > - } > - > - req_lib_confdb_key_get.header.size = sizeof (struct req_lib_confdb_key_get); > - req_lib_confdb_key_get.header.id = MESSAGE_REQ_CONFDB_KEY_INCREMENT; > - req_lib_confdb_key_get.parent_object_handle = parent_object_handle; > - memcpy(req_lib_confdb_key_get.key_name.value, key_name, key_name_len); > - req_lib_confdb_key_get.key_name.length = key_name_len; > - > - iov.iov_base = (char *)&req_lib_confdb_key_get; > - iov.iov_len = sizeof (struct req_lib_confdb_key_get); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res_lib_confdb_key_incdec, > - sizeof (struct res_lib_confdb_key_incdec), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = res_lib_confdb_key_incdec.header.error; > - if (error == CS_OK) { > - *value = res_lib_confdb_key_incdec.value; > - } > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > -cs_error_t confdb_key_decrement ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - unsigned int *value) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct req_lib_confdb_key_get req_lib_confdb_key_get; > - struct res_lib_confdb_key_incdec res_lib_confdb_key_incdec; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_key_decrement(parent_object_handle, > - key_name, key_name_len, > - value)) > - error = CS_ERR_ACCESS; > - goto error_exit; > - } > - > - req_lib_confdb_key_get.header.size = sizeof (struct req_lib_confdb_key_get); > - req_lib_confdb_key_get.header.id = MESSAGE_REQ_CONFDB_KEY_DECREMENT; > - req_lib_confdb_key_get.parent_object_handle = parent_object_handle; > - memcpy(req_lib_confdb_key_get.key_name.value, key_name, key_name_len); > - req_lib_confdb_key_get.key_name.length = key_name_len; > - > - iov.iov_base = (char *)&req_lib_confdb_key_get; > - iov.iov_len = sizeof (struct req_lib_confdb_key_get); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res_lib_confdb_key_incdec, > - sizeof (struct res_lib_confdb_key_incdec), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = res_lib_confdb_key_incdec.header.error; > - if (error == CS_OK) { > - *value = res_lib_confdb_key_incdec.value; > - } > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > -cs_error_t confdb_key_replace ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - const void *old_value, > - size_t old_value_len, > - const void *new_value, > - size_t new_value_len) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct req_lib_confdb_key_replace req_lib_confdb_key_replace; > - struct qb_ipc_response_header res; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_key_replace(parent_object_handle, > - key_name, key_name_len, > - old_value, old_value_len, > - new_value, new_value_len)) > - error = CS_ERR_ACCESS; > - goto error_exit; > - } > - req_lib_confdb_key_replace.header.size = sizeof (struct req_lib_confdb_key_replace); > - req_lib_confdb_key_replace.header.id = MESSAGE_REQ_CONFDB_KEY_REPLACE; > - req_lib_confdb_key_replace.object_handle = parent_object_handle; > - memcpy(req_lib_confdb_key_replace.key_name.value, key_name, key_name_len); > - req_lib_confdb_key_replace.key_name.length = key_name_len; > - memcpy(req_lib_confdb_key_replace.old_value.value, old_value, old_value_len); > - req_lib_confdb_key_replace.old_value.length = old_value_len; > - memcpy(req_lib_confdb_key_replace.new_value.value, new_value, new_value_len); > - req_lib_confdb_key_replace.new_value.length = new_value_len; > - > - iov.iov_base = (char *)&req_lib_confdb_key_replace; > - iov.iov_len = sizeof (struct req_lib_confdb_key_replace); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res, > - sizeof (res), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = res.error; > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > -cs_error_t confdb_object_iter_start ( > - confdb_handle_t handle, > - hdb_handle_t object_handle) > -{ > - struct confdb_inst *confdb_inst; > - cs_error_t error = CS_OK; > - struct iter_context *context; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - context = find_iter_context(&confdb_inst->object_iter_head, object_handle); > - if (!context) { > - context = malloc(sizeof(struct iter_context)); > - if (!context) { > - error = CS_ERR_NO_MEMORY; > - goto ret; > - } > - context->parent_object_handle = object_handle; > - context->find_handle = 0; > - list_add(&context->list, &confdb_inst->object_iter_head); > - } > - > - /* Start a new find context */ > - if (context->find_handle) { > - (void)do_find_destroy(confdb_inst, context->find_handle); > - context->find_handle = 0; > - } > - > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > -ret: > - return error; > -} > - > -cs_error_t confdb_key_iter_start ( > - confdb_handle_t handle, > - hdb_handle_t object_handle) > -{ > - struct confdb_inst *confdb_inst; > - cs_error_t error = CS_OK; > - struct iter_context *context; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - context = find_iter_context(&confdb_inst->key_iter_head, object_handle); > - if (!context) { > - context = malloc(sizeof(struct iter_context)); > - if (!context) { > - error = CS_ERR_NO_MEMORY; > - goto ret; > - } > - context->parent_object_handle = object_handle; > - list_add(&context->list, &confdb_inst->key_iter_head); > - } > - > - context->find_handle = 0; > - context->next_entry = 0; > - > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > -ret: > - return error; > -} > - > -cs_error_t confdb_object_find_start ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle) > -{ > - struct confdb_inst *confdb_inst; > - cs_error_t error = CS_OK; > - struct iter_context *context; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - context = find_iter_context(&confdb_inst->object_find_head, parent_object_handle); > - if (!context) { > - context = malloc(sizeof(struct iter_context)); > - if (!context) { > - error = CS_ERR_NO_MEMORY; > - goto ret; > - } > - context->find_handle = 0; > - context->parent_object_handle = parent_object_handle; > - list_add(&context->list, &confdb_inst->object_find_head); > - } > - /* Start a new find context */ > - if (context->find_handle) { > - (void)do_find_destroy(confdb_inst, context->find_handle); > - context->find_handle = 0; > - } > - > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > -ret: > - return error; > -} > - > -cs_error_t confdb_object_find ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *object_name, > - size_t object_name_len, > - hdb_handle_t *object_handle) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct iter_context *context; > - struct req_lib_confdb_object_find req_lib_confdb_object_find; > - struct res_lib_confdb_object_find res_lib_confdb_object_find; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - /* You MUST call confdb_object_find_start first */ > - context = find_iter_context(&confdb_inst->object_find_head, parent_object_handle); > - if (!context) { > - error = CS_ERR_CONTEXT_NOT_FOUND; > - goto error_exit; > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_object_find(parent_object_handle, > - &context->find_handle, > - object_handle, > - object_name, object_name_len)) > - error = CS_ERR_ACCESS; > - goto error_exit; > - } > - > - req_lib_confdb_object_find.header.size = sizeof (struct req_lib_confdb_object_find); > - req_lib_confdb_object_find.header.id = MESSAGE_REQ_CONFDB_OBJECT_FIND; > - req_lib_confdb_object_find.parent_object_handle = parent_object_handle; > - req_lib_confdb_object_find.find_handle = context->find_handle; > - memcpy(req_lib_confdb_object_find.object_name.value, object_name, object_name_len); > - req_lib_confdb_object_find.object_name.length = object_name_len; > - > - iov.iov_base = (char *)&req_lib_confdb_object_find; > - iov.iov_len = sizeof (struct req_lib_confdb_object_find); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res_lib_confdb_object_find, > - sizeof (struct res_lib_confdb_object_find), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = res_lib_confdb_object_find.header.error; > - *object_handle = res_lib_confdb_object_find.object_handle; > - context->find_handle = res_lib_confdb_object_find.find_handle; > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > - > -cs_error_t confdb_object_iter ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - hdb_handle_t *object_handle, > - void *object_name, > - size_t *object_name_len) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct iter_context *context; > - struct req_lib_confdb_object_iter req_lib_confdb_object_iter; > - struct res_lib_confdb_object_iter res_lib_confdb_object_iter; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - /* You MUST call confdb_object_iter_start first */ > - context = find_iter_context(&confdb_inst->object_iter_head, parent_object_handle); > - if (!context) { > - error = CS_ERR_CONTEXT_NOT_FOUND; > - goto error_exit; > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - *object_name_len = 0; > - if (confdb_sa_object_iter(parent_object_handle, > - &context->find_handle, > - object_handle, > - NULL, 0, > - object_name, object_name_len)) > - error = CS_ERR_ACCESS; > - goto sa_exit; > - } > - > - req_lib_confdb_object_iter.header.size = sizeof (struct req_lib_confdb_object_iter); > - req_lib_confdb_object_iter.header.id = MESSAGE_REQ_CONFDB_OBJECT_ITER; > - req_lib_confdb_object_iter.parent_object_handle = parent_object_handle; > - req_lib_confdb_object_iter.find_handle = context->find_handle; > - > - iov.iov_base = (char *)&req_lib_confdb_object_iter; > - iov.iov_len = sizeof (struct req_lib_confdb_object_iter); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res_lib_confdb_object_iter, > - sizeof (struct res_lib_confdb_object_iter), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = res_lib_confdb_object_iter.header.error; > - if (error == CS_OK) { > - *object_name_len = res_lib_confdb_object_iter.object_name.length; > - memcpy(object_name, res_lib_confdb_object_iter.object_name.value, *object_name_len); > - *object_handle = res_lib_confdb_object_iter.object_handle; > - context->find_handle = res_lib_confdb_object_iter.find_handle; > - } > -sa_exit: > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > -cs_error_t confdb_key_iter ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - void *key_name, > - size_t *key_name_len, > - void *value, > - size_t *value_len) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct iter_context *context; > - struct req_lib_confdb_key_iter req_lib_confdb_key_iter; > - struct res_lib_confdb_key_iter res_lib_confdb_key_iter; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - /* You MUST call confdb_key_iter_start first */ > - context = find_iter_context(&confdb_inst->key_iter_head, parent_object_handle); > - if (!context) { > - error = CS_ERR_CONTEXT_NOT_FOUND; > - goto error_exit; > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_key_iter(parent_object_handle, > - context->next_entry, > - key_name, key_name_len, > - value, value_len)) > - error = CS_ERR_ACCESS; > - goto sa_exit; > - } > - > - req_lib_confdb_key_iter.header.size = sizeof (struct req_lib_confdb_key_iter); > - req_lib_confdb_key_iter.header.id = MESSAGE_REQ_CONFDB_KEY_ITER; > - req_lib_confdb_key_iter.parent_object_handle = parent_object_handle; > - req_lib_confdb_key_iter.next_entry= context->next_entry; > - > - iov.iov_base = (char *)&req_lib_confdb_key_iter; > - iov.iov_len = sizeof (struct req_lib_confdb_key_iter); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res_lib_confdb_key_iter, > - sizeof (struct res_lib_confdb_key_iter), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = res_lib_confdb_key_iter.header.error; > - if (error == CS_OK) { > - char* key_name_str = (char*)key_name; > - *key_name_len = res_lib_confdb_key_iter.key_name.length; > - memcpy(key_name, res_lib_confdb_key_iter.key_name.value, *key_name_len); > - key_name_str[res_lib_confdb_key_iter.key_name.length] = '\0'; > - *value_len = res_lib_confdb_key_iter.value.length; > - memcpy(value, res_lib_confdb_key_iter.value.value, *value_len); > - } > - > -sa_exit: > - context->next_entry++; > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > -cs_error_t confdb_key_iter_typed ( > - confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - char *key_name, > - void *value, > - size_t *value_len, > - confdb_value_types_t *type) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct iter_context *context; > - struct req_lib_confdb_key_iter req_lib_confdb_key_iter; > - struct res_lib_confdb_key_iter_typed response; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - /* You MUST call confdb_key_iter_start first */ > - context = find_iter_context(&confdb_inst->key_iter_head, parent_object_handle); > - if (!context) { > - error = CS_ERR_CONTEXT_NOT_FOUND; > - goto error_exit; > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_key_iter_typed(parent_object_handle, > - context->next_entry, > - key_name, > - value, value_len, (int*)type)) > - error = CS_ERR_ACCESS; > - goto sa_exit; > - } > - > - req_lib_confdb_key_iter.header.size = sizeof (struct req_lib_confdb_key_iter); > - req_lib_confdb_key_iter.header.id = MESSAGE_REQ_CONFDB_KEY_ITER_TYPED; > - req_lib_confdb_key_iter.parent_object_handle = parent_object_handle; > - req_lib_confdb_key_iter.next_entry= context->next_entry; > - > - iov.iov_base = (char *)&req_lib_confdb_key_iter; > - iov.iov_len = sizeof (struct req_lib_confdb_key_iter); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &response, > - sizeof (struct res_lib_confdb_key_iter_typed), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = response.header.error; > - if (error == CS_OK) { > - memcpy(key_name, response.key_name.value, response.key_name.length); > - key_name[response.key_name.length] = '\0'; > - *value_len = response.value.length; > - memcpy(value, response.value.value, *value_len); > - *type = response.type; > - } > - > -sa_exit: > - context->next_entry++; > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > -cs_error_t confdb_write ( > - confdb_handle_t handle, > - char *error_text, > - size_t errbuf_len) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct qb_ipc_request_header req; > - struct res_lib_confdb_write res_lib_confdb_write; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - /* FIXME: set error_text */ > - return (error); > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_write(error_text, errbuf_len)) > - error = CS_ERR_ACCESS; > - goto error_exit; > - } > - > - req.size = sizeof (struct qb_ipc_request_header); > - req.id = MESSAGE_REQ_CONFDB_WRITE; > - > - iov.iov_base = (char *)&req; > - iov.iov_len = sizeof (struct qb_ipc_request_header); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res_lib_confdb_write, > - sizeof (struct res_lib_confdb_write), -1)); > - > - if (error != CS_OK) { > - /* FIXME: set error_text */ > - goto error_exit; > - } > - > - error = res_lib_confdb_write.header.error; > - if (res_lib_confdb_write.error.length) { > - memcpy(error_text, res_lib_confdb_write.error.value, > - QB_MIN(res_lib_confdb_write.error.length,errbuf_len)); > - error_text[errbuf_len-1] = '\0'; > - } > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > -cs_error_t confdb_reload ( > - confdb_handle_t handle, > - int flush, > - char *error_text, > - size_t errbuf_len) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct res_lib_confdb_reload res_lib_confdb_reload; > - struct req_lib_confdb_reload req_lib_confdb_reload; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - /* FIXME: set error_text */ > - return (error); > - } > - > - if (confdb_inst->standalone) { > - error = CS_OK; > - > - if (confdb_sa_reload(flush, error_text, errbuf_len)) > - error = CS_ERR_ACCESS; > - goto error_exit; > - } > - > - req_lib_confdb_reload.header.size = sizeof (req_lib_confdb_reload); > - req_lib_confdb_reload.header.id = MESSAGE_REQ_CONFDB_RELOAD; > - req_lib_confdb_reload.flush = flush; > - > - iov.iov_base = (char *)&req_lib_confdb_reload; > - iov.iov_len = sizeof (req_lib_confdb_reload); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res_lib_confdb_reload, > - sizeof (struct res_lib_confdb_reload), -1)); > - > - if (error != CS_OK) { > - /* FIXME: set error_text */ > - goto error_exit; > - } > - > - error = res_lib_confdb_reload.header.error; > - if(res_lib_confdb_reload.error.length) { > - memcpy(error_text, res_lib_confdb_reload.error.value, > - QB_MIN(res_lib_confdb_reload.error.length,errbuf_len)); > - error_text[errbuf_len-1] = '\0'; > - } > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > -cs_error_t confdb_track_changes ( > - confdb_handle_t handle, > - hdb_handle_t object_handle, > - unsigned int flags) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct req_lib_confdb_object_track_start req; > - struct qb_ipc_response_header res; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - if (confdb_inst->standalone) { > - error = CS_ERR_NOT_SUPPORTED; > - goto error_exit; > - } > - > - req.header.size = sizeof (struct req_lib_confdb_object_track_start); > - req.header.id = MESSAGE_REQ_CONFDB_TRACK_START; > - req.object_handle = object_handle; > - req.flags = flags; > - > - iov.iov_base = (char *)&req; > - iov.iov_len = sizeof (struct req_lib_confdb_object_track_start); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res, > - sizeof (struct qb_ipc_response_header), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = res.error; > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > -cs_error_t confdb_stop_track_changes (confdb_handle_t handle) > -{ > - cs_error_t error; > - struct confdb_inst *confdb_inst; > - struct iovec iov; > - struct qb_ipc_request_header req; > - struct qb_ipc_response_header res; > - > - error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, (void *)&confdb_inst)); > - if (error != CS_OK) { > - return (error); > - } > - > - if (confdb_inst->standalone) { > - error = CS_ERR_NOT_SUPPORTED; > - goto error_exit; > - } > - > - req.size = sizeof (struct qb_ipc_request_header); > - req.id = MESSAGE_REQ_CONFDB_TRACK_STOP; > - > - iov.iov_base = (char *)&req; > - iov.iov_len = sizeof (struct qb_ipc_request_header); > - > - error = qb_to_cs_error (qb_ipcc_sendv_recv ( > - confdb_inst->c, > - &iov, > - 1, > - &res, > - sizeof (struct qb_ipc_response_header), -1)); > - > - if (error != CS_OK) { > - goto error_exit; > - } > - > - error = res.error; > - > -error_exit: > - (void)hdb_handle_put (&confdb_handle_t_db, handle); > - > - return (error); > -} > - > -/** > - * @} > - */ > diff --git a/lib/libconfdb.versions b/lib/libconfdb.versions > deleted file mode 100644 > index 588ce9f..0000000 > --- a/lib/libconfdb.versions > +++ /dev/null > @@ -1,24 +0,0 @@ > -# Version and symbol export for libconfdb.so > - > -COROSYNC_CONFDB_1.0 { > - global: > - confdb_initialize; > - confdb_finalize; > - confdb_fd_get; > - confdb_dispatch; > - confdb_track_changes; > - confdb_stop_track_changes; > - confdb_object_create; > - confdb_object_destroy; > - confdb_object_parent_get; > - confdb_key_create; > - confdb_key_delete; > - confdb_key_get; > - confdb_key_replace; > - confdb_object_find_start; > - confdb_object_find; > - confdb_object_iter_start; > - confdb_object_iter; > - confdb_key_iter_start; > - confdb_key_iter; > -}; > diff --git a/lib/libconfdb.verso b/lib/libconfdb.verso > deleted file mode 100644 > index ee74734..0000000 > --- a/lib/libconfdb.verso > +++ /dev/null > @@ -1 +0,0 @@ > -4.1.0 > diff --git a/lib/sa-confdb.c b/lib/sa-confdb.c > deleted file mode 100644 > index bf7bc3e..0000000 > --- a/lib/sa-confdb.c > +++ /dev/null > @@ -1,449 +0,0 @@ > -/* > - * Copyright (c) 2008, 2009 Red Hat, Inc. > - * > - * All rights reserved. > - * > - * Author: Christine Caulfield (ccaulfie@xxxxxxxxxx) > - * > - * 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. > - */ > -/* > - * Provides stand-alone access to data in the corosync object database > - * when aisexec is not running. > - */ > - > -#include <config.h> > - > -#include <stdlib.h> > -#include <string.h> > -#include <unistd.h> > -#include <sys/types.h> > -#include <errno.h> > - > -#include <corosync/corotypes.h> > -#include <qb/qbipcc.h> > -#include <corosync/engine/objdb.h> > -#include <corosync/engine/config.h> > -#include <corosync/engine/logsys.h> > -#include <corosync/lcr/lcr_comp.h> > -#include <corosync/lcr/lcr_ifact.h> > - > -#include "sa-confdb.h" > - > -static struct objdb_iface_ver0 *objdb; > - > -static int num_config_modules; > - > -static struct config_iface_ver0 *config_modules[128]; > - > -void main_get_config_modules(struct config_iface_ver0 ***modules, int *num); > - > -static int load_objdb(void) > -{ > - hdb_handle_t objdb_handle; > - void *objdb_p; > - int res; > - > - /* > - * Load the object database interface > - */ > - res = lcr_ifact_reference ( > - &objdb_handle, > - "objdb", > - 0, > - &objdb_p, > - (void *)0); > - if (res == -1) { > - return -1; > - } > - > - objdb = (struct objdb_iface_ver0 *)objdb_p; > - > - objdb->objdb_init (); > - return CS_OK; > -} > - > -static int load_config(void) > -{ > - char *config_iface; > - char *iface; > - int res; > - hdb_handle_t config_handle; > - hdb_handle_t config_version = 0; > - void *config_p; > - struct config_iface_ver0 *config; > -// const char *error_string; > - char *strtok_savept; > - > - /* User's bootstrap config service */ > - config_iface = getenv("COROSYNC_DEFAULT_CONFIG_IFACE"); > - if (!config_iface) { > - if ((config_iface = strdup("corosync_parser")) == NULL) { > - return -1; > - } > - } > - > - /* Make a copy so we can deface it with strtok */ > - if ((config_iface = strdup(config_iface)) == NULL) { > - return -1; > - } > - > - iface = strtok_r (config_iface, ":", &strtok_savept); > - while (iface) > - { > - res = lcr_ifact_reference ( > - &config_handle, > - iface, > - config_version, > - &config_p, > - 0); > - > - config = (struct config_iface_ver0 *)config_p; > - if (res == -1) { > - return -1; > - } > - > -// res = config->config_readconfig(objdb, &error_string); > - if (res == -1) { > - return -1; > - } > - > - config_modules[num_config_modules++] = config; > - > - iface = strtok_r (NULL, ":", &strtok_savept); > - } > - free(config_iface); > - > - return CS_OK; > -} > - > -/* Needed by objdb when it writes back the configuration */ > -void main_get_config_modules(struct config_iface_ver0 ***modules, int *num) > -{ > - *modules = config_modules; > - *num = num_config_modules; > -} > - > -int confdb_sa_init (void) > -{ > - int res; > - > - res = load_objdb(); > - if (res != CS_OK) > - return res; > - > - res = load_config(); > - > - return res; > -} > - > - > -int confdb_sa_object_create ( > - hdb_handle_t parent_object_handle, > - const void *object_name, > - size_t object_name_len, > - hdb_handle_t *object_handle) > -{ > - return objdb->object_create(parent_object_handle, > - object_handle, > - object_name, object_name_len); > -} > - > -int confdb_sa_object_destroy ( > - hdb_handle_t object_handle) > -{ > - return objdb->object_destroy(object_handle); > -} > - > -int confdb_sa_object_parent_get ( > - hdb_handle_t object_handle, > - hdb_handle_t *parent_object_handle) > -{ > - return objdb->object_parent_get(object_handle, parent_object_handle); > -} > - > -int confdb_sa_object_name_get( > - hdb_handle_t object_handle, > - char *object_name, > - size_t *object_name_len) > -{ > - return objdb->object_name_get(object_handle, object_name, object_name_len); > -} > - > -int confdb_sa_key_create ( > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - const void *value, > - size_t value_len) > -{ > - return objdb->object_key_create(parent_object_handle, > - key_name, key_name_len, > - value, value_len); > -} > - > -int confdb_sa_key_create_typed ( > - hdb_handle_t parent_object_handle, > - const char *key_name, > - const void *value, > - size_t value_len, > - int type) > -{ > - return objdb->object_key_create_typed(parent_object_handle, > - key_name, > - value, value_len, type); > -} > - > -int confdb_sa_key_delete ( > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - const void *value, > - size_t value_len) > -{ > - return objdb->object_key_delete(parent_object_handle, > - key_name, key_name_len); > -} > - > -int confdb_sa_key_get ( > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - void *value, > - size_t *value_len) > -{ > - int res; > - void *kvalue; > - > - res = objdb->object_key_get(parent_object_handle, > - key_name, key_name_len, > - &kvalue, value_len); > - if (!res) { > - memcpy(value, kvalue, *value_len); > - } > - return res; > -} > - > -int confdb_sa_key_get_typed ( > - hdb_handle_t parent_object_handle, > - const char *key_name, > - void *value, > - size_t *value_len, > - int *type) > -{ > - int res; > - void *kvalue; > - > - res = objdb->object_key_get_typed(parent_object_handle, > - key_name, > - &kvalue, value_len, (objdb_value_types_t*)type); > - if (!res) { > - memcpy(value, kvalue, *value_len); > - } > - return res; > -} > - > -int confdb_sa_key_increment ( > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - unsigned int *value) > -{ > - int res; > - > - res = objdb->object_key_increment(parent_object_handle, > - key_name, key_name_len, > - value); > - return res; > -} > - > -int confdb_sa_key_decrement ( > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - unsigned int *value) > -{ > - int res; > - > - res = objdb->object_key_decrement(parent_object_handle, > - key_name, key_name_len, > - value); > - return res; > -} > - > - > -int confdb_sa_key_replace ( > - hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - const void *old_value, > - size_t old_value_len, > - const void *new_value, > - size_t new_value_len) > -{ > - return objdb->object_key_replace(parent_object_handle, > - key_name, key_name_len, > - new_value, new_value_len); > -} > - > -int confdb_sa_write (char *error_text, size_t errbuf_len) > -{ > - const char *errtext; > - int ret; > - > - ret = objdb->object_write_config(&errtext); > - if (!ret) { > - strncpy(error_text, errtext, errbuf_len); > - if (errbuf_len > 0) > - error_text[errbuf_len-1] = '\0'; > - } > - > - return ret; > -} > - > -int confdb_sa_reload ( > - int flush, > - char *error_text, > - size_t errbuf_len) > -{ > - char *errtext; > - int ret; > - > - ret = objdb->object_reload_config(flush, (const char **) &errtext); > - if (!ret) { > - strncpy(error_text, errtext, errbuf_len); > - if (errbuf_len > 0) > - error_text[errbuf_len-1] = '\0'; > - } > - > - return ret; > -} > - > -int confdb_sa_object_find ( > - hdb_handle_t parent_object_handle, > - hdb_handle_t *find_handle, > - hdb_handle_t *object_handle, > - const void *object_name, > - size_t object_name_len) > -{ > - int res; > - > - if (!*find_handle) { > - objdb->object_find_create(parent_object_handle, > - object_name, object_name_len, > - find_handle); > - } > - > - res = objdb->object_find_next(*find_handle, > - object_handle); > - return res; > -} > - > -int confdb_sa_object_iter ( > - hdb_handle_t parent_object_handle, > - hdb_handle_t *find_handle, > - hdb_handle_t *object_handle, > - const void *object_name, > - size_t object_name_len, > - void *found_object_name, > - size_t *found_object_name_len) > -{ > - int res; > - > - if (!*find_handle) { > - objdb->object_find_create(parent_object_handle, > - object_name, object_name_len, > - find_handle); > - } > - > - res = objdb->object_find_next(*find_handle, > - object_handle); > - /* Return object name if we were called as _iter */ > - if (!res) { > - objdb->object_name_get(*object_handle, > - found_object_name, found_object_name_len); > - } > - return res; > -} > - > -int confdb_sa_key_iter ( > - hdb_handle_t parent_object_handle, > - hdb_handle_t start_pos, > - void *key_name, > - size_t *key_name_len, > - void *value, > - size_t *value_len) > -{ > - int res; > - void *kname, *kvalue; > - > - res = objdb->object_key_iter_from(parent_object_handle, > - start_pos, > - &kname, key_name_len, > - &kvalue, value_len); > - > - if (!res) { > - memcpy(key_name, kname, *key_name_len); > - memcpy(value, kvalue, *value_len); > - } > - return res; > -} > - > -int confdb_sa_key_iter_typed ( > - hdb_handle_t parent_object_handle, > - hdb_handle_t start_pos, > - char *key_name, > - void *value, > - size_t *value_len, > - int *type) > -{ > - int res; > - void *kname; > - void *kvalue; > - size_t key_name_len; > - > - res = objdb->object_key_iter_from(parent_object_handle, > - start_pos, > - &kname, &key_name_len, > - &kvalue, value_len); > - > - if (!res) { > - memcpy(key_name, kname, key_name_len); > - key_name[key_name_len] = '\0'; > - memcpy(value, kvalue, *value_len); > - > - objdb->object_key_get_typed(parent_object_handle, > - key_name, > - &kvalue, value_len, (objdb_value_types_t*)type); > - } > - return res; > -} > - > -int confdb_sa_find_destroy(hdb_handle_t find_handle) > -{ > - return objdb->object_find_destroy(find_handle); > -} > diff --git a/lib/sa-confdb.h b/lib/sa-confdb.h > deleted file mode 100644 > index 61a0fa7..0000000 > --- a/lib/sa-confdb.h > +++ /dev/null > @@ -1,112 +0,0 @@ > -/* > - * Copyright (c) 2008, 2009 Red Hat, Inc. > - * > - * All rights reserved. > - * > - * Author: Christine Caulfield (ccaulfie@xxxxxxxxxx) > - * > - * 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. > - */ > - > -extern int confdb_sa_init(void); > -extern int confdb_sa_object_create(hdb_handle_t parent_object_handle, > - const void *object_name, > - size_t object_name_len, > - hdb_handle_t *object_handle); > -extern int confdb_sa_object_destroy(hdb_handle_t object_handle); > -extern int confdb_sa_object_parent_get(hdb_handle_t object_handle, > - hdb_handle_t *parent_object_handle); > -extern int confdb_sa_object_name_get(hdb_handle_t object_handle, > - char *object_name, > - size_t *object_name_len); > -extern int confdb_sa_key_create(hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - const void *value, > - size_t value_len); > -extern int confdb_sa_key_create_typed (hdb_handle_t parent_object_handle, > - const char *key_name, > - const void *value, > - size_t value_len, > - int type); > -extern int confdb_sa_key_delete(hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - const void *value, > - size_t value_len); > -extern int confdb_sa_key_get(hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - void *value, > - size_t *value_len); > -extern int confdb_sa_key_get_typed(hdb_handle_t parent_object_handle, > - const char *key_name, > - void *value, > - size_t *value_len, > - int *type); > -extern int confdb_sa_key_replace(hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - const void *old_value, > - size_t old_value_len, > - const void *new_value, > - size_t new_value_len); > -extern int confdb_sa_object_find(hdb_handle_t parent_object_handle, > - hdb_handle_t *find_handle, > - hdb_handle_t *object_handle, > - const void *object_name, > - size_t object_name_len); > -extern int confdb_sa_object_iter(hdb_handle_t parent_object_handle, > - hdb_handle_t *find_handle, > - hdb_handle_t *object_handle, > - const void *object_name, > - size_t object_name_len, > - void *found_object_name, > - size_t *found_object_name_len); > -extern int confdb_sa_key_iter(hdb_handle_t parent_object_handle, > - hdb_handle_t start_pos, > - void *key_name, > - size_t *key_name_len, > - void *value, > - size_t *value_len); > -extern int confdb_sa_key_iter_typed (hdb_handle_t parent_object_handle, > - hdb_handle_t start_pos, > - char *key_name, > - void *value, > - size_t *value_len, > - int *type); > -extern int confdb_sa_key_increment(hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - unsigned int *value); > -extern int confdb_sa_key_decrement(hdb_handle_t parent_object_handle, > - const void *key_name, > - size_t key_name_len, > - unsigned int *value); > -extern int confdb_sa_find_destroy(hdb_handle_t find_handle); > -extern int confdb_sa_write(char *error_text, size_t errbuf_len); > -extern int confdb_sa_reload(int flush, char *error_text, size_t errbuf_len); > diff --git a/pkgconfig/Makefile.am b/pkgconfig/Makefile.am > index 2414199..238fd0d 100644 > --- a/pkgconfig/Makefile.am > +++ b/pkgconfig/Makefile.am > @@ -32,8 +32,8 @@ MAINTAINERCLEANFILES = Makefile.in > > EXTRA_DIST = libtemplate.pc.in corosync.pc.in > > -LIBS = cfg confdb cpg evs pload quorum \ > - totem_pg votequorum sam > +LIBS = cfg cpg evs pload quorum \ > + totem_pg votequorum sam cmap > > target_LIBS = $(LIBS:%=lib%.pc) > > diff --git a/services/Makefile.am b/services/Makefile.am > index 376363d..2ac4a03 100644 > --- a/services/Makefile.am > +++ b/services/Makefile.am > @@ -37,7 +37,7 @@ INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ > -I$(top_builddir)/include/corosync \ > -I$(top_srcdir)/include/corosync > > -SERVICE_LCRSO = evs cfg cpg confdb pload cmap > +SERVICE_LCRSO = evs cfg cpg pload cmap > if BUILD_WATCHDOG > SERVICE_LCRSO += wd > endif > diff --git a/services/confdb.c b/services/confdb.c > deleted file mode 100644 > index 65a48ab..0000000 > --- a/services/confdb.c > +++ /dev/null > @@ -1,1094 +0,0 @@ > -/* > - * Copyright (c) 2008-2010 Red Hat, Inc. > - * > - * All rights reserved. > - * > - * Author: Christine Caulfield (ccaulfie@xxxxxxxxxx) > - * > - * 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 CONTIBUTORS "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 <config.h> > - > -#include <sys/types.h> > -#include <unistd.h> > -#include <fcntl.h> > -#include <stdlib.h> > -#include <errno.h> > -#include <unistd.h> > -#include <poll.h> > -#include <assert.h> > - > -#include <qb/qbloop.h> > -#include <qb/qbipc_common.h> > - > -#include <corosync/corotypes.h> > -#include <corosync/corodefs.h> > -#include <corosync/cfg.h> > -#include <corosync/list.h> > -#include <corosync/mar_gen.h> > -#include <corosync/ipc_confdb.h> > -#include <corosync/lcr/lcr_comp.h> > -#include <corosync/engine/logsys.h> > -#include <corosync/engine/coroapi.h> > - > -LOGSYS_DECLARE_SUBSYS ("CONFDB"); > - > -static hdb_handle_t * > -m2h (mar_uint64_t *m) > -{ > - /* FIXME enable the following when/if we use gnulib: > - (it's a compile-time assertion; i.e., zero run-time cost) > - verify (sizeof (*m) == sizeof (hdb_handle_t)); */ > - return (void *) m; > -} > - > -static struct corosync_api_v1 *api; > - > -static int notify_pipe[2]; > - > -struct confdb_ipc_message_holder { > - void *conn; > - size_t mlen; > - struct list_head list; > - char msg[]; > -}; > - > -DECLARE_LIST_INIT(confdb_ipc_message_holder_list_head); > - > -pthread_mutex_t confdb_ipc_message_holder_list_mutex = > - PTHREAD_MUTEX_INITIALIZER; > - > -static int confdb_exec_init_fn ( > - struct corosync_api_v1 *corosync_api); > -static int confdb_exec_exit_fn(void); > - > -static int fd_set_nonblocking(int fd); > - > -static int objdb_notify_dispatch(int fd, int revents, void *data); > - > - > - > -static int confdb_lib_init_fn (void *conn); > -static int confdb_lib_exit_fn (void *conn); > - > -static void message_handler_req_lib_confdb_object_create (void *conn, > - const void *message); > -static void message_handler_req_lib_confdb_object_destroy (void *conn, > - const void *message); > -static void message_handler_req_lib_confdb_object_find_destroy (void *conn, > - const void *message); > - > -static void message_handler_req_lib_confdb_key_create (void *conn, > - const void *message); > -static void message_handler_req_lib_confdb_key_create_typed (void *conn, > - const void *message); > -static void message_handler_req_lib_confdb_key_get (void *conn, > - const void *message); > -static void message_handler_req_lib_confdb_key_get_typed (void *conn, > - const void *message); > -static void message_handler_req_lib_confdb_key_replace (void *conn, > - const void *message); > -static void message_handler_req_lib_confdb_key_delete (void *conn, > - const void *message); > -static void message_handler_req_lib_confdb_key_iter (void *conn, > - const void *message); > -static void message_handler_req_lib_confdb_key_iter_typed (void *conn, > - const void *message); > - > -static void message_handler_req_lib_confdb_key_increment (void *conn, > - const void *message); > -static void message_handler_req_lib_confdb_key_decrement (void *conn, > - const void *message); > - > -static void message_handler_req_lib_confdb_object_iter (void *conn, > - const void *message); > -static void message_handler_req_lib_confdb_object_find (void *conn, > - const void *message); > - > -static void message_handler_req_lib_confdb_object_parent_get (void *conn, > - const void *message); > -static void message_handler_req_lib_confdb_object_name_get (void *conn, > - const void *message); > -static void message_handler_req_lib_confdb_write (void *conn, > - const void *message); > -static void message_handler_req_lib_confdb_reload (void *conn, > - const void *message); > - > -static void message_handler_req_lib_confdb_track_start (void *conn, > - const void *message); > -static void message_handler_req_lib_confdb_track_stop (void *conn, > - const void *message); > - > -static void confdb_notify_lib_of_key_change( > - object_change_type_t change_type, > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *object_name_pt, size_t object_name_len, > - const void *key_name_pt, size_t key_name_len, > - const void *key_value_pt, size_t key_value_len, > - void *priv_data_pt); > - > -static void confdb_notify_lib_of_new_object( > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *name_pt, size_t name_len, > - void *priv_data_pt); > - > -static void confdb_notify_lib_of_destroyed_object( > - hdb_handle_t parent_object_handle, > - const void *name_pt, size_t name_len, > - void *priv_data_pt); > - > -static void confdb_notify_lib_of_reload( > - objdb_reload_notify_type_t notify_type, > - int flush, > - void *priv_data_pt); > - > -/* > - * Library Handler Definition > - */ > -static struct corosync_lib_handler confdb_lib_engine[] = > -{ > - { /* 0 */ > - .lib_handler_fn = message_handler_req_lib_confdb_object_create, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 1 */ > - .lib_handler_fn = message_handler_req_lib_confdb_object_destroy, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 2 */ > - .lib_handler_fn = message_handler_req_lib_confdb_object_find, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 3 */ > - .lib_handler_fn = message_handler_req_lib_confdb_key_create, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 4 */ > - .lib_handler_fn = message_handler_req_lib_confdb_key_get, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 5 */ > - .lib_handler_fn = message_handler_req_lib_confdb_key_replace, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 6 */ > - .lib_handler_fn = message_handler_req_lib_confdb_key_delete, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 7 */ > - .lib_handler_fn = message_handler_req_lib_confdb_object_iter, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 8 */ > - .lib_handler_fn = message_handler_req_lib_confdb_object_parent_get, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 9 */ > - .lib_handler_fn = message_handler_req_lib_confdb_key_iter, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 10 */ > - .lib_handler_fn = message_handler_req_lib_confdb_track_start, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 11 */ > - .lib_handler_fn = message_handler_req_lib_confdb_track_stop, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 12 */ > - .lib_handler_fn = message_handler_req_lib_confdb_write, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 13 */ > - .lib_handler_fn = message_handler_req_lib_confdb_reload, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 14 */ > - .lib_handler_fn = message_handler_req_lib_confdb_object_find_destroy, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 15 */ > - .lib_handler_fn = message_handler_req_lib_confdb_key_increment, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 16 */ > - .lib_handler_fn = message_handler_req_lib_confdb_key_decrement, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 17 */ > - .lib_handler_fn = message_handler_req_lib_confdb_key_create_typed, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 18 */ > - .lib_handler_fn = message_handler_req_lib_confdb_key_get_typed, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 19 */ > - .lib_handler_fn = message_handler_req_lib_confdb_key_iter_typed, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > - { /* 20 */ > - .lib_handler_fn = message_handler_req_lib_confdb_object_name_get, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED > - }, > -}; > - > - > -struct corosync_service_engine confdb_service_engine = { > - .name = "corosync cluster config database access v1.01", > - .id = CONFDB_SERVICE, > - .priority = 1, > - .private_data_size = 0, > - .flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED, > - .allow_inquorate = CS_LIB_ALLOW_INQUORATE, > - .lib_init_fn = confdb_lib_init_fn, > - .lib_exit_fn = confdb_lib_exit_fn, > - .lib_engine = confdb_lib_engine, > - .lib_engine_count = sizeof (confdb_lib_engine) / sizeof (struct corosync_lib_handler), > - .exec_init_fn = confdb_exec_init_fn, > - .exec_exit_fn = confdb_exec_exit_fn, > -}; > - > -/* > - * Dynamic loader definition > - */ > -static struct corosync_service_engine *confdb_get_service_engine_ver0 (void); > - > -static struct corosync_service_engine_iface_ver0 confdb_service_engine_iface = { > - .corosync_get_service_engine_ver0 = confdb_get_service_engine_ver0 > -}; > - > -static struct lcr_iface corosync_confdb_ver0[1] = { > - { > - .name = "corosync_confdb", > - .version = 0, > - .versions_replace = 0, > - .versions_replace_count = 0, > - .dependencies = 0, > - .dependency_count = 0, > - .constructor = NULL, > - .destructor = NULL, > - .interfaces = NULL > - } > -}; > - > -static struct lcr_comp confdb_comp_ver0 = { > - .iface_count = 1, > - .ifaces = corosync_confdb_ver0 > -}; > - > - > -static struct corosync_service_engine *confdb_get_service_engine_ver0 (void) > -{ > - return (&confdb_service_engine); > -} > - > -#ifdef COROSYNC_SOLARIS > -void corosync_lcr_component_register (void); > - > -void corosync_lcr_component_register (void) { > -#else > -__attribute__ ((constructor)) static void corosync_lcr_component_register (void) { > -#endif > - lcr_interfaces_set (&corosync_confdb_ver0[0], &confdb_service_engine_iface); > - > - lcr_component_register (&confdb_comp_ver0); > -} > - > -static int confdb_exec_exit_fn(void) > -{ > - api->poll_dispatch_delete(api->poll_handle_get(), notify_pipe[0]); > - close(notify_pipe[0]); > - close(notify_pipe[1]); > - return 0; > -} > - > -static int confdb_exec_init_fn ( > - struct corosync_api_v1 *corosync_api) > -{ > - int i; > - > -#ifdef COROSYNC_SOLARIS > - logsys_subsys_init(); > -#endif > - api = corosync_api; > - > - if (pipe(notify_pipe) != 0) { > - return -1; > - } > - > - for (i = 0; i < 2; i++) { > - if (fd_set_nonblocking (notify_pipe[i]) == -1) { > - return -1; > - } > - } > - > - return api->poll_dispatch_add(api->poll_handle_get(), notify_pipe[0], > - POLLIN, NULL, objdb_notify_dispatch); > -} > - > -static int confdb_lib_init_fn (void *conn) > -{ > - log_printf(LOGSYS_LEVEL_DEBUG, "lib_init_fn: conn=%p\n", conn); > - return (0); > -} > - > -static int confdb_lib_exit_fn (void *conn) > -{ > - log_printf(LOGSYS_LEVEL_DEBUG, "exit_fn for conn=%p\n", conn); > - /* cleanup the object trackers for this client. */ > - api->object_track_stop(confdb_notify_lib_of_key_change, > - confdb_notify_lib_of_new_object, > - confdb_notify_lib_of_destroyed_object, > - confdb_notify_lib_of_reload, > - conn); > - return (0); > -} > - > -static int fd_set_nonblocking(int fd) > -{ > - int flags; > - int res; > - > - flags = fcntl (fd, F_GETFL); > - if (flags == -1) { > - return -1; > - } > - > - flags |= O_NONBLOCK; > - > - res = fcntl (fd, F_SETFL, flags); > - > - return res; > -} > - > -static void message_handler_req_lib_confdb_object_create (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_object_create *req_lib_confdb_object_create > - = message; > - struct res_lib_confdb_object_create res_lib_confdb_object_create; > - hdb_handle_t object_handle; > - int ret = CS_OK; > - > - if (api->object_create(req_lib_confdb_object_create->parent_object_handle, > - &object_handle, > - req_lib_confdb_object_create->object_name.value, > - req_lib_confdb_object_create->object_name.length)) > - ret = CS_ERR_ACCESS; > - > - res_lib_confdb_object_create.object_handle = object_handle; > - res_lib_confdb_object_create.header.size = sizeof(res_lib_confdb_object_create); > - res_lib_confdb_object_create.header.id = MESSAGE_RES_CONFDB_OBJECT_CREATE; > - res_lib_confdb_object_create.header.error = ret; > - api->ipc_response_send(conn, &res_lib_confdb_object_create, sizeof(res_lib_confdb_object_create)); > -} > - > -static void message_handler_req_lib_confdb_object_destroy (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_object_destroy *req_lib_confdb_object_destroy > - = message; > - struct qb_ipc_response_header res; > - int ret = CS_OK; > - > - if (api->object_destroy(req_lib_confdb_object_destroy->object_handle)) > - ret = CS_ERR_ACCESS; > - > - res.size = sizeof(res); > - res.id = MESSAGE_RES_CONFDB_OBJECT_DESTROY; > - res.error = ret; > - api->ipc_response_send(conn, &res, sizeof(res)); > -} > - > -static void message_handler_req_lib_confdb_object_find_destroy (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_object_find_destroy > - *req_lib_confdb_object_find_destroy = message; > - struct qb_ipc_response_header res; > - int ret = CS_OK; > - > - if (api->object_find_destroy(req_lib_confdb_object_find_destroy->find_handle)) > - ret = CS_ERR_ACCESS; > - > - res.size = sizeof(res); > - res.id = MESSAGE_RES_CONFDB_OBJECT_FIND_DESTROY; > - res.error = ret; > - api->ipc_response_send(conn, &res, sizeof(res)); > -} > - > - > -static void message_handler_req_lib_confdb_key_create (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_key_create *req_lib_confdb_key_create > - = message; > - struct qb_ipc_response_header res; > - int ret = CS_OK; > - > - if (api->object_key_create(req_lib_confdb_key_create->object_handle, > - req_lib_confdb_key_create->key_name.value, > - req_lib_confdb_key_create->key_name.length, > - req_lib_confdb_key_create->value.value, > - req_lib_confdb_key_create->value.length)) > - ret = CS_ERR_ACCESS; > - > - res.size = sizeof(res); > - res.id = MESSAGE_RES_CONFDB_KEY_CREATE; > - res.error = ret; > - api->ipc_response_send(conn, &res, sizeof(res)); > -} > - > -static void message_handler_req_lib_confdb_key_create_typed (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_key_create_typed *req_lib_confdb_key_create > - = message; > - struct qb_ipc_response_header res; > - int ret = CS_OK; > - > - if (api->object_key_create_typed(req_lib_confdb_key_create->object_handle, > - (char*)req_lib_confdb_key_create->key_name.value, > - req_lib_confdb_key_create->value.value, > - req_lib_confdb_key_create->value.length, > - req_lib_confdb_key_create->type)) > - ret = CS_ERR_ACCESS; > - > - res.size = sizeof(res); > - res.id = MESSAGE_RES_CONFDB_KEY_CREATE; > - res.error = ret; > - api->ipc_response_send(conn, &res, sizeof(res)); > -} > - > -static void message_handler_req_lib_confdb_key_get (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_key_get *req_lib_confdb_key_get = message; > - struct res_lib_confdb_key_get res_lib_confdb_key_get; > - size_t value_len; > - void *value; > - int ret = CS_OK; > - > - if (api->object_key_get(req_lib_confdb_key_get->parent_object_handle, > - req_lib_confdb_key_get->key_name.value, > - req_lib_confdb_key_get->key_name.length, > - &value, > - &value_len)) > - ret = CS_ERR_ACCESS; > - else { > - memcpy(res_lib_confdb_key_get.value.value, value, value_len); > - res_lib_confdb_key_get.value.length = value_len; > - > - } > - res_lib_confdb_key_get.header.size = sizeof(res_lib_confdb_key_get); > - res_lib_confdb_key_get.header.id = MESSAGE_RES_CONFDB_KEY_GET; > - res_lib_confdb_key_get.header.error = ret; > - api->ipc_response_send(conn, &res_lib_confdb_key_get, sizeof(res_lib_confdb_key_get)); > -} > - > -static void message_handler_req_lib_confdb_key_get_typed (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_key_get *req_lib_confdb_key_get = message; > - struct res_lib_confdb_key_get_typed res_lib_confdb_key_get; > - size_t value_len; > - void *value; > - int ret = CS_OK; > - objdb_value_types_t type; > - char * key_name = (char*)req_lib_confdb_key_get->key_name.value; > - key_name[req_lib_confdb_key_get->key_name.length] = '\0'; > - > - if (api->object_key_get_typed(req_lib_confdb_key_get->parent_object_handle, > - key_name, > - &value, > - &value_len, &type)) > - ret = CS_ERR_ACCESS; > - else { > - memcpy(res_lib_confdb_key_get.value.value, value, value_len); > - res_lib_confdb_key_get.value.length = value_len; > - res_lib_confdb_key_get.type = type; > - > - } > - res_lib_confdb_key_get.header.size = sizeof(res_lib_confdb_key_get); > - res_lib_confdb_key_get.header.id = MESSAGE_RES_CONFDB_KEY_GET_TYPED; > - res_lib_confdb_key_get.header.error = ret; > - api->ipc_response_send(conn, &res_lib_confdb_key_get, sizeof(res_lib_confdb_key_get)); > -} > - > -static void message_handler_req_lib_confdb_key_increment (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_key_get *req_lib_confdb_key_get = message; > - struct res_lib_confdb_key_incdec res_lib_confdb_key_incdec; > - int ret = CS_OK; > - > - if (api->object_key_increment(req_lib_confdb_key_get->parent_object_handle, > - req_lib_confdb_key_get->key_name.value, > - req_lib_confdb_key_get->key_name.length, > - &res_lib_confdb_key_incdec.value)) > - ret = CS_ERR_ACCESS; > - > - res_lib_confdb_key_incdec.header.size = sizeof(res_lib_confdb_key_incdec); > - res_lib_confdb_key_incdec.header.id = MESSAGE_RES_CONFDB_KEY_INCREMENT; > - res_lib_confdb_key_incdec.header.error = ret; > - api->ipc_response_send(conn, &res_lib_confdb_key_incdec, sizeof(res_lib_confdb_key_incdec)); > -} > - > -static void message_handler_req_lib_confdb_key_decrement (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_key_get *req_lib_confdb_key_get = message; > - struct res_lib_confdb_key_incdec res_lib_confdb_key_incdec; > - int ret = CS_OK; > - > - if (api->object_key_decrement(req_lib_confdb_key_get->parent_object_handle, > - req_lib_confdb_key_get->key_name.value, > - req_lib_confdb_key_get->key_name.length, > - &res_lib_confdb_key_incdec.value)) > - ret = CS_ERR_ACCESS; > - > - res_lib_confdb_key_incdec.header.size = sizeof(res_lib_confdb_key_incdec); > - res_lib_confdb_key_incdec.header.id = MESSAGE_RES_CONFDB_KEY_DECREMENT; > - res_lib_confdb_key_incdec.header.error = ret; > - api->ipc_response_send(conn, &res_lib_confdb_key_incdec, sizeof(res_lib_confdb_key_incdec)); > -} > - > -static void message_handler_req_lib_confdb_key_replace (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_key_replace *req_lib_confdb_key_replace > - = message; > - struct qb_ipc_response_header res; > - int ret = CS_OK; > - > - if (api->object_key_replace(req_lib_confdb_key_replace->object_handle, > - req_lib_confdb_key_replace->key_name.value, > - req_lib_confdb_key_replace->key_name.length, > - req_lib_confdb_key_replace->new_value.value, > - req_lib_confdb_key_replace->new_value.length)) > - ret = CS_ERR_ACCESS; > - > - res.size = sizeof(res); > - res.id = MESSAGE_RES_CONFDB_KEY_REPLACE; > - res.error = ret; > - api->ipc_response_send(conn, &res, sizeof(res)); > -} > - > -static void message_handler_req_lib_confdb_key_delete (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_key_delete *req_lib_confdb_key_delete > - = message; > - struct qb_ipc_response_header res; > - int ret = CS_OK; > - > - if (api->object_key_delete(req_lib_confdb_key_delete->object_handle, > - req_lib_confdb_key_delete->key_name.value, > - req_lib_confdb_key_delete->key_name.length)) > - ret = CS_ERR_ACCESS; > - > - res.size = sizeof(res); > - res.id = MESSAGE_RES_CONFDB_KEY_DELETE; > - res.error = ret; > - api->ipc_response_send(conn, &res, sizeof(res)); > -} > - > -static void message_handler_req_lib_confdb_object_parent_get (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_object_parent_get > - *req_lib_confdb_object_parent_get = message; > - struct res_lib_confdb_object_parent_get res_lib_confdb_object_parent_get; > - hdb_handle_t object_handle; > - int ret = CS_OK; > - > - if (api->object_parent_get(req_lib_confdb_object_parent_get->object_handle, > - &object_handle)) > - ret = CS_ERR_ACCESS; > - > - res_lib_confdb_object_parent_get.parent_object_handle = object_handle; > - res_lib_confdb_object_parent_get.header.size = sizeof(res_lib_confdb_object_parent_get); > - res_lib_confdb_object_parent_get.header.id = MESSAGE_RES_CONFDB_OBJECT_PARENT_GET; > - res_lib_confdb_object_parent_get.header.error = ret; > - api->ipc_response_send(conn, &res_lib_confdb_object_parent_get, sizeof(res_lib_confdb_object_parent_get)); > -} > - > -static void message_handler_req_lib_confdb_object_name_get (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_object_name_get *request = message; > - struct res_lib_confdb_object_name_get response; > - int ret = CS_OK; > - char object_name[CS_MAX_NAME_LENGTH]; > - size_t object_name_len; > - > - if (api->object_name_get(request->object_handle, > - object_name, &object_name_len)) { > - ret = CS_ERR_ACCESS; > - } > - > - response.object_name.length = object_name_len; > - strncpy((char*)response.object_name.value, object_name, CS_MAX_NAME_LENGTH); > - response.object_name.value[CS_MAX_NAME_LENGTH-1] = '\0'; > - response.header.size = sizeof(response); > - response.header.id = MESSAGE_RES_CONFDB_OBJECT_NAME_GET; > - response.header.error = ret; > - api->ipc_response_send(conn, &response, sizeof(response)); > -} > - > -static void message_handler_req_lib_confdb_key_iter (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_key_iter *req_lib_confdb_key_iter = message; > - struct res_lib_confdb_key_iter res_lib_confdb_key_iter; > - void *key_name; > - size_t key_name_len; > - void *value; > - size_t value_len; > - int ret = CS_OK; > - > - if (api->object_key_iter_from(req_lib_confdb_key_iter->parent_object_handle, > - req_lib_confdb_key_iter->next_entry, > - &key_name, > - &key_name_len, > - &value, > - &value_len)) > - ret = CS_ERR_ACCESS; > - else { > - memcpy(res_lib_confdb_key_iter.key_name.value, key_name, key_name_len); > - memcpy(res_lib_confdb_key_iter.value.value, value, value_len); > - res_lib_confdb_key_iter.key_name.length = key_name_len; > - res_lib_confdb_key_iter.value.length = value_len; > - } > - res_lib_confdb_key_iter.header.size = sizeof(res_lib_confdb_key_iter); > - res_lib_confdb_key_iter.header.id = MESSAGE_RES_CONFDB_KEY_ITER; > - res_lib_confdb_key_iter.header.error = ret; > - > - api->ipc_response_send(conn, &res_lib_confdb_key_iter, sizeof(res_lib_confdb_key_iter)); > -} > - > -static void message_handler_req_lib_confdb_key_iter_typed (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_key_iter *req_lib_confdb_key_iter = message; > - struct res_lib_confdb_key_iter_typed res_lib_confdb_key_iter; > - void *key_name; > - size_t key_name_len; > - void *value; > - size_t value_len; > - int ret = CS_OK; > - objdb_value_types_t my_type; > - > - if (api->object_key_iter_from(req_lib_confdb_key_iter->parent_object_handle, > - req_lib_confdb_key_iter->next_entry, > - &key_name, > - &key_name_len, > - &value, > - &value_len)) > - ret = CS_ERR_ACCESS; > - else { > - memcpy(res_lib_confdb_key_iter.key_name.value, key_name, key_name_len); > - memcpy(res_lib_confdb_key_iter.value.value, value, value_len); > - res_lib_confdb_key_iter.key_name.length = key_name_len; > - res_lib_confdb_key_iter.key_name.value[key_name_len] = '\0'; > - res_lib_confdb_key_iter.value.length = value_len; > - api->object_key_get_typed(req_lib_confdb_key_iter->parent_object_handle, > - (const char*)res_lib_confdb_key_iter.key_name.value, > - &value, > - &value_len, > - &my_type); > - res_lib_confdb_key_iter.type = my_type; > - } > - res_lib_confdb_key_iter.header.size = sizeof(res_lib_confdb_key_iter); > - res_lib_confdb_key_iter.header.id = MESSAGE_RES_CONFDB_KEY_ITER_TYPED; > - res_lib_confdb_key_iter.header.error = ret; > - > - api->ipc_response_send(conn, &res_lib_confdb_key_iter, sizeof(res_lib_confdb_key_iter)); > -} > - > -static void message_handler_req_lib_confdb_object_iter (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_object_iter *req_lib_confdb_object_iter > - = message; > - struct res_lib_confdb_object_iter res_lib_confdb_object_iter; > - size_t object_name_len; > - int ret = CS_OK; > - > - if (!req_lib_confdb_object_iter->find_handle) { > - if (api->object_find_create(req_lib_confdb_object_iter->parent_object_handle, > - NULL, 0, > - m2h(&res_lib_confdb_object_iter.find_handle)) == -1) { > - ret = CS_ERR_ACCESS; > - goto response_send; > - } > - } > - else > - res_lib_confdb_object_iter.find_handle = req_lib_confdb_object_iter->find_handle; > - > - if (api->object_find_next(res_lib_confdb_object_iter.find_handle, > - m2h(&res_lib_confdb_object_iter.object_handle))) { > - ret = CS_ERR_ACCESS; > - api->object_find_destroy(res_lib_confdb_object_iter.find_handle); > - } > - else { > - if (api->object_name_get(res_lib_confdb_object_iter.object_handle, > - (char *)res_lib_confdb_object_iter.object_name.value, > - &object_name_len) == -1) { > - ret = CS_ERR_ACCESS; > - goto response_send; > - } else { > - res_lib_confdb_object_iter.object_name.length = object_name_len; > - } > - } > - > -response_send: > - res_lib_confdb_object_iter.header.size = sizeof(res_lib_confdb_object_iter); > - res_lib_confdb_object_iter.header.id = MESSAGE_RES_CONFDB_OBJECT_ITER; > - res_lib_confdb_object_iter.header.error = ret; > - > - api->ipc_response_send(conn, &res_lib_confdb_object_iter, sizeof(res_lib_confdb_object_iter)); > -} > - > -static void message_handler_req_lib_confdb_object_find (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_object_find *req_lib_confdb_object_find > - = message; > - struct res_lib_confdb_object_find res_lib_confdb_object_find; > - int ret = CS_OK; > - > - if (!req_lib_confdb_object_find->find_handle) { > - if (api->object_find_create(req_lib_confdb_object_find->parent_object_handle, > - req_lib_confdb_object_find->object_name.value, > - req_lib_confdb_object_find->object_name.length, > - m2h(&res_lib_confdb_object_find.find_handle)) == -1) { > - ret = CS_ERR_ACCESS; > - goto response_send; > - } > - } > - else > - res_lib_confdb_object_find.find_handle = req_lib_confdb_object_find->find_handle; > - > - if (api->object_find_next(res_lib_confdb_object_find.find_handle, > - m2h(&res_lib_confdb_object_find.object_handle))) { > - ret = CS_ERR_ACCESS; > - api->object_find_destroy(res_lib_confdb_object_find.find_handle); > - } > - > - > -response_send: > - res_lib_confdb_object_find.header.size = sizeof(res_lib_confdb_object_find); > - res_lib_confdb_object_find.header.id = MESSAGE_RES_CONFDB_OBJECT_FIND; > - res_lib_confdb_object_find.header.error = ret; > - > - > - api->ipc_response_send(conn, &res_lib_confdb_object_find, sizeof(res_lib_confdb_object_find)); > -} > - > -static void message_handler_req_lib_confdb_write (void *conn, > - const void *message) > -{ > - struct res_lib_confdb_write res_lib_confdb_write; > - int ret = CS_OK; > - const char *error_string = NULL; > - > - if (api->object_write_config(&error_string)) > - ret = CS_ERR_ACCESS; > - > - res_lib_confdb_write.header.size = sizeof(res_lib_confdb_write); > - res_lib_confdb_write.header.id = MESSAGE_RES_CONFDB_WRITE; > - res_lib_confdb_write.header.error = ret; > - if (error_string) { > - strcpy((char *)res_lib_confdb_write.error.value, error_string); > - res_lib_confdb_write.error.length = strlen(error_string) + 1; > - } else > - res_lib_confdb_write.error.length = 0; > - > - api->ipc_response_send(conn, &res_lib_confdb_write, sizeof(res_lib_confdb_write)); > -} > - > -static void message_handler_req_lib_confdb_reload (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_reload *req_lib_confdb_reload = message; > - struct res_lib_confdb_reload res_lib_confdb_reload; > - int ret = CS_OK; > - const char *error_string = NULL; > - > - if (api->object_reload_config(req_lib_confdb_reload->flush, &error_string)) > - ret = CS_ERR_ACCESS; > - > - res_lib_confdb_reload.header.size = sizeof(res_lib_confdb_reload); > - res_lib_confdb_reload.header.id = MESSAGE_RES_CONFDB_RELOAD; > - res_lib_confdb_reload.header.error = ret; > - > - if(error_string) { > - strcpy((char *)res_lib_confdb_reload.error.value, error_string); > - res_lib_confdb_reload.error.length = strlen(error_string) + 1; > - } else > - res_lib_confdb_reload.error.length = 0; > - > - api->ipc_response_send(conn, &res_lib_confdb_reload, sizeof(res_lib_confdb_reload)); > -} > - > -static int objdb_notify_dispatch(int fd, int revents, void *data) > -{ > - struct confdb_ipc_message_holder *holder; > - ssize_t rc; > - char pipe_cmd; > - > - if (revents & POLLHUP) { > - return -1; > - } > - > - pthread_mutex_lock (&confdb_ipc_message_holder_list_mutex); > - > -retry_read: > - rc = read(fd, &pipe_cmd, sizeof(pipe_cmd)); > - if (rc == sizeof(pipe_cmd)) { > - goto retry_read; /* Flush whole buffer */ > - } > - > - if (rc == -1) { > - if (errno == EINTR) { > - goto retry_read; > - } > - > - if (errno != EAGAIN && errno != EWOULDBLOCK) { > - goto unlock_exit; > - } > - } else { > - goto unlock_exit; /* rc != -1 && rc != 1 -> end of file */ > - } > - > - while (!list_empty (&confdb_ipc_message_holder_list_head)) { > - holder = list_entry (confdb_ipc_message_holder_list_head.next, > - struct confdb_ipc_message_holder, list); > - > - list_del (&holder->list); > - > - /* > - * All list operations are done now, so unlock list mutex to > - * prevent deadlock in IPC. > - */ > - pthread_mutex_unlock (&confdb_ipc_message_holder_list_mutex); > - > - api->ipc_dispatch_send(holder->conn, holder->msg, holder->mlen); > - > - api->ipc_refcnt_dec(holder->conn); > - > - free(holder); > - > - /* > - * Next operation is again list one, so lock list again. > - */ > - pthread_mutex_lock (&confdb_ipc_message_holder_list_mutex); > - } > - > -unlock_exit: > - pthread_mutex_unlock (&confdb_ipc_message_holder_list_mutex); > - > - return 0; > -} > - > -static int32_t ipc_dispatch_send_from_poll_thread(void *conn, const void *msg, size_t mlen) > -{ > - struct confdb_ipc_message_holder *holder; > - ssize_t written; > - size_t holder_size; > - char pipe_cmd; > - > - api->ipc_refcnt_inc(conn); > - > - holder_size = sizeof (*holder) + mlen; > - holder = malloc (holder_size); > - if (holder == NULL) { > - api->ipc_refcnt_dec(conn); > - return -1; > - } > - > - memset(holder, 0, holder_size); > - holder->conn = conn; > - holder->mlen = mlen; > - memcpy(holder->msg, msg, mlen); > - list_init(&holder->list); > - > - pthread_mutex_lock (&confdb_ipc_message_holder_list_mutex); > - > - list_add_tail (&holder->list, &confdb_ipc_message_holder_list_head); > - > - pipe_cmd = 'M'; /* Message */ > -retry_write: > - written = write(notify_pipe[1], &pipe_cmd, sizeof(pipe_cmd)); > - > - if (written == -1) { > - if (errno == EINTR) { > - goto retry_write; > - } > - > - if (errno != EAGAIN && errno != EWOULDBLOCK) { > - /* > - * Different error then EINTR or BLOCK -> exit with error > - */ > - goto refcnt_del_unlock_exit; > - } > - } else if (written != sizeof (pipe_cmd)) { > - goto refcnt_del_unlock_exit; > - } > - pthread_mutex_unlock (&confdb_ipc_message_holder_list_mutex); > - > - return 0; > - > -refcnt_del_unlock_exit: > - list_del (&holder->list); > - free(holder); > - api->ipc_refcnt_dec(conn); > - pthread_mutex_unlock (&confdb_ipc_message_holder_list_mutex); > - > - return -1; > -} > - > -static void confdb_notify_lib_of_key_change(object_change_type_t change_type, > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *object_name_pt, size_t object_name_len, > - const void *key_name_pt, size_t key_name_len, > - const void *key_value_pt, size_t key_value_len, > - void *priv_data_pt) > -{ > - struct res_lib_confdb_key_change_callback res; > - > - res.header.size = sizeof(res); > - res.header.id = MESSAGE_RES_CONFDB_KEY_CHANGE_CALLBACK; > - res.header.error = CS_OK; > -// handle & type > - res.change_type = change_type; > - res.parent_object_handle = parent_object_handle; > - res.object_handle = object_handle; > -//object > - memcpy(res.object_name.value, object_name_pt, object_name_len); > - res.object_name.length = object_name_len; > -//key name > - memcpy(res.key_name.value, key_name_pt, key_name_len); > - res.key_name.length = key_name_len; > -//key value > - memcpy(res.key_value.value, key_value_pt, key_value_len); > - res.key_value.length = key_value_len; > - > - ipc_dispatch_send_from_poll_thread(priv_data_pt, &res, sizeof(res)); > -} > - > -static void confdb_notify_lib_of_new_object(hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *name_pt, size_t name_len, > - void *priv_data_pt) > -{ > - struct res_lib_confdb_object_create_callback res; > - > - res.header.size = sizeof(res); > - res.header.id = MESSAGE_RES_CONFDB_OBJECT_CREATE_CALLBACK; > - res.header.error = CS_OK; > - res.parent_object_handle = parent_object_handle; > - res.object_handle = object_handle; > - memcpy(res.name.value, name_pt, name_len); > - res.name.length = name_len; > - > - ipc_dispatch_send_from_poll_thread(priv_data_pt, &res, sizeof(res)); > -} > - > -static void confdb_notify_lib_of_destroyed_object( > - hdb_handle_t parent_object_handle, > - const void *name_pt, size_t name_len, > - void *priv_data_pt) > -{ > - struct res_lib_confdb_object_destroy_callback res; > - > - res.header.size = sizeof(res); > - res.header.id = MESSAGE_RES_CONFDB_OBJECT_DESTROY_CALLBACK; > - res.header.error = CS_OK; > - res.parent_object_handle = parent_object_handle; > - memcpy(res.name.value, name_pt, name_len); > - res.name.length = name_len; > - > - ipc_dispatch_send_from_poll_thread(priv_data_pt, &res, sizeof(res)); > -} > - > -static void confdb_notify_lib_of_reload(objdb_reload_notify_type_t notify_type, > - int flush, > - void *priv_data_pt) > -{ > - struct res_lib_confdb_reload_callback res; > - > - res.header.size = sizeof(res); > - res.header.id = MESSAGE_RES_CONFDB_RELOAD_CALLBACK; > - res.header.error = CS_OK; > - res.type = notify_type; > - > - ipc_dispatch_send_from_poll_thread(priv_data_pt, &res, sizeof(res)); > -} > - > - > -static void message_handler_req_lib_confdb_track_start (void *conn, > - const void *message) > -{ > - const struct req_lib_confdb_object_track_start *req = message; > - struct qb_ipc_response_header res; > - > - api->object_track_start(req->object_handle, > - req->flags, > - confdb_notify_lib_of_key_change, > - confdb_notify_lib_of_new_object, > - confdb_notify_lib_of_destroyed_object, > - confdb_notify_lib_of_reload, > - conn); > - res.size = sizeof(res); > - res.id = MESSAGE_RES_CONFDB_TRACK_START; > - res.error = CS_OK; > - api->ipc_response_send(conn, &res, sizeof(res)); > -} > - > -static void message_handler_req_lib_confdb_track_stop (void *conn, > - const void *message) > -{ > - struct qb_ipc_response_header res; > - > - api->object_track_stop(confdb_notify_lib_of_key_change, > - confdb_notify_lib_of_new_object, > - confdb_notify_lib_of_destroyed_object, > - confdb_notify_lib_of_reload, > - conn); > - > - res.size = sizeof(res); > - res.id = MESSAGE_RES_CONFDB_TRACK_STOP; > - res.error = CS_OK; > - api->ipc_response_send(conn, &res, sizeof(res)); > -} > diff --git a/test/.gitignore b/test/.gitignore > index 344fad9..d0b2f27 100644 > --- a/test/.gitignore > +++ b/test/.gitignore > @@ -10,7 +10,6 @@ logsysbench > logsysrec > stress_cpgcontext > stress_cpgfdget > -testconfdb > testcpg > testcpg2 > testevs > diff --git a/test/Makefile.am b/test/Makefile.am > index 0f1c818..7c9453b 100644 > --- a/test/Makefile.am > +++ b/test/Makefile.am > @@ -33,7 +33,7 @@ > MAINTAINERCLEANFILES = Makefile.in > INCLUDES = -I$(top_builddir)/include/corosync -I$(top_srcdir)/include > > -noinst_PROGRAMS = testevs evsbench evsverify cpgverify testcpg testcpg2 cpgbench testconfdb \ > +noinst_PROGRAMS = testevs evsbench evsverify cpgverify testcpg testcpg2 cpgbench \ > testquorum testvotequorum1 testvotequorum2 \ > stress_cpgfdget stress_cpgcontext cpgbound testsam \ > testcpgzc cpgbenchzc testzcgc stress_cpgzc \ > @@ -55,8 +55,6 @@ stress_cpgfdget_LDADD = -lcpg $(LIBQB_LIBS) > stress_cpgfdget_LDFLAGS = -L../lib > stress_cpgcontext_LDADD = -lcpg $(LIBQB_LIBS) > stress_cpgcontext_LDFLAGS = -L../lib > -testconfdb_LDADD = -lconfdb ../lcr/liblcr.a $(LIBQB_LIBS) > -testconfdb_LDFLAGS = -L../lib > testquorum_LDADD = -lquorum $(LIBQB_LIBS) > testquorum_LDFLAGS = -L../lib > testvotequorum1_LDADD = -lvotequorum $(LIBQB_LIBS) > diff --git a/test/testconfdb.c b/test/testconfdb.c > deleted file mode 100644 > index 3017a69..0000000 > --- a/test/testconfdb.c > +++ /dev/null > @@ -1,259 +0,0 @@ > -/* > - * Copyright (c) 2008, 2009 Red Hat Inc > - * > - * All rights reserved. > - * > - * Author: Christine Caulfield <ccaulfie@xxxxxxxxxx> > - * > - * 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 <config.h> > - > -#include <stdio.h> > -#include <stdlib.h> > -#include <errno.h> > -#include <unistd.h> > -#include <string.h> > -#include <sys/types.h> > -#include <sys/un.h> > - > -#include <corosync/corotypes.h> > -#include <corosync/confdb.h> > - > -#define INCDEC_VALUE 45 > - > -/* Callbacks are not supported yet */ > -confdb_callbacks_t callbacks = { > - .confdb_key_change_notify_fn = NULL, > - .confdb_object_create_change_notify_fn = NULL, > - .confdb_object_delete_change_notify_fn = NULL > -}; > - > -/* Recursively dump the object tree */ > -static void print_config_tree(confdb_handle_t handle, hdb_handle_t parent_object_handle, int depth) > -{ > - hdb_handle_t object_handle; > - char object_name[1024]; > - size_t object_name_len; > - char key_name[1024]; > - size_t key_name_len; > - char key_value[1024]; > - size_t key_value_len; > - int res; > - int i; > - > - /* Show the keys */ > - res = confdb_key_iter_start(handle, parent_object_handle); > - if (res != CS_OK) { > - printf( "error resetting key iterator for object "HDB_X_FORMAT": %d\n", parent_object_handle, res); > - return; > - } > - > - while ( (res = confdb_key_iter(handle, parent_object_handle, key_name, &key_name_len, > - key_value, &key_value_len)) == CS_OK) { > - key_name[key_name_len] = '\0'; > - key_value[key_value_len] = '\0'; > - for (i=0; i<depth; i++) printf(" "); > - printf(" KEY %s=%s\n", key_name, key_value); > - } > - > - /* Show sub-objects */ > - res = confdb_object_iter_start(handle, parent_object_handle); > - if (res != CS_OK) { > - printf( "error resetting object iterator for object "HDB_X_FORMAT": %d\n", parent_object_handle, res); > - return; > - } > - > - while ( (res = confdb_object_iter(handle, parent_object_handle, &object_handle, object_name, &object_name_len)) == CS_OK) { > - hdb_handle_t parent; > - > - res = confdb_object_parent_get(handle, object_handle, &parent); > - if (res != CS_OK) { > - printf( "error getting parent for object "HDB_X_FORMAT": %d\n", object_handle, res); > - return; > - } > - > - for (i=0; i<depth; i++) printf(" "); > - > - object_name[object_name_len] = '\0'; > - printf("OBJECT: %s ("HDB_X_FORMAT", parent: "HDB_X_FORMAT")\n", object_name, object_handle, parent); > - > - /* Down we go ... */ > - print_config_tree(handle, object_handle, depth+1); > - } > -} > - > -static void do_write_tests(confdb_handle_t handle) > -{ > - int res; > - unsigned int incdec_value; > - hdb_handle_t object_handle; > - char error_string[1024]; > - > - /* Add a scratch object and put some keys into it */ > - res = confdb_object_create(handle, OBJECT_PARENT_HANDLE, "testconfdb", strlen("testconfdb"), &object_handle); > - if (res != CS_OK) { > - printf( "error creating 'testconfdb' object: %d\n", res); > - return; > - } > - > - res = confdb_key_create(handle, object_handle, "testkey", strlen("testkey"), "one", strlen("one")); > - if (res != CS_OK) { > - printf( "error creating 'testconfdb' key 1: %d\n", res); > - return; > - } > - > - res = confdb_key_create(handle, object_handle, "testkey", strlen("testkey"), "two", strlen("two")); > - if (res != CS_OK) { > - printf( "error creating 'testconfdb' key 2: %d\n", res); > - return; > - } > - > - res = confdb_key_create(handle, object_handle, "grot", strlen("grot"), "perrins", strlen("perrins")); > - if (res != CS_OK) { > - printf( "error creating 'testconfdb' key 3: %d\n", res); > - return; > - } > - > - res = confdb_key_replace(handle, object_handle, "testkey", strlen("testkey"), "two", strlen("two"), > - "newtwo", strlen("newtwo")); > - > - if (res != CS_OK) { > - printf( "error replace 'testconfdb' key 2: %d\n", res); > - return; > - } > - > - /* Print it for verification */ > - print_config_tree(handle, object_handle, 0); > - > - incdec_value = INCDEC_VALUE; > - res = confdb_key_create(handle, object_handle, "incdec", strlen("incdec"), &incdec_value, sizeof(incdec_value)); > - if (res != CS_OK) { > - printf( "error creating 'testconfdb' key 4: %d\n", res); > - return; > - } > - res = confdb_key_increment(handle, object_handle, "incdec", strlen("incdec"), &incdec_value); > - if (res != CS_OK) { > - printf( "error incrementing 'testconfdb' key 4: %d\n", res); > - return; > - } > - if (incdec_value == INCDEC_VALUE+1) > - printf("incremented value = %d\n", incdec_value); > - else > - printf("ERROR: incremented value = %d (should be %d)\n", incdec_value, INCDEC_VALUE+1); > - > - res = confdb_key_decrement(handle, object_handle, "incdec", strlen("incdec"), &incdec_value); > - if (res != CS_OK) { > - printf( "error decrementing 'testconfdb' key 4: %d\n", res); > - return; > - } > - if (incdec_value == INCDEC_VALUE) > - printf("decremented value = %d\n", incdec_value); > - else > - printf("ERROR: decremented value = %d (should be %d)\n", incdec_value, INCDEC_VALUE); > - > - printf("-------------------------\n"); > - > - /* Remove it. > - Check that it doesn't exist when the full tree dump runs next */ > - res = confdb_object_destroy(handle, object_handle); > - if (res != CS_OK) { > - printf( "error destroying 'testconfdb' object: %d\n", res); > - return; > - } > - > - res = confdb_write(handle, error_string, sizeof error_string); > - printf("confdb_write returned %d: %s\n", res, error_string); > -} > - > - > -int main (int argc, char *argv[]) { > - confdb_handle_t handle; > - int result; > - hdb_handle_t totem_handle; > - char key_value[256]; > - size_t value_len; > - > - result = confdb_initialize (&handle, &callbacks); > - if (result != CS_OK) { > - printf ("Could not initialize Cluster Configuration Database API instance error %d\n", result); > - exit (1); > - } > - > - if (argv[1] && strcmp(argv[1], "write")==0) > - do_write_tests(handle); > - > - if (argv[1] && strcmp(argv[1], "reload")==0) { > - /* Test reload interface */ > - result = confdb_reload(handle, 0, key_value, sizeof key_value); > - printf ("Try to reload the config (noflush): %d (should be 1)\n", result); > - > - result = confdb_reload(handle, 1, key_value, sizeof key_value); > - printf ("Try to reload the config (flush): %d (should be 1)\n", result); > - } > - > - /* Test iterators */ > - print_config_tree(handle, OBJECT_PARENT_HANDLE, 0); > - > - /* Find "totem" and dump bits of it again, to test the direct APIs */ > - result = confdb_object_find_start(handle, OBJECT_PARENT_HANDLE); > - if (result != CS_OK) { > - printf ("Could not start object_find %d\n", result); > - exit (1); > - } > - > - result = confdb_object_find(handle, OBJECT_PARENT_HANDLE, "totem", strlen("totem"), &totem_handle); > - if (result != CS_OK) { > - printf ("Could not object_find \"totem\": %d\n", result); > - exit (1); > - } > - > - result = confdb_key_get(handle, totem_handle, "version", strlen("version"), key_value, &value_len); > - if (result != CS_OK) { > - printf ("Could not get \"version\" key: %d\n", result); > - exit (1); > - } > - key_value[value_len] = '\0'; > - printf("totem/version = '%s'\n", key_value); > - > - result = confdb_key_get(handle, totem_handle, "secauth", strlen("secauth"), key_value, &value_len); > - if (result != CS_OK) { > - printf ("Could not get \"secauth\" key: %d\n", result); > - exit (1); > - } > - key_value[value_len] = '\0'; > - printf("totem/secauth = '%s'\n", key_value); > - > - /* Try a call that fails */ > - result = confdb_key_get(handle, totem_handle, "grot", strlen("grot"), key_value, &value_len); > - printf ("Get \"grot\" key returned: %d (should fail)\n", result); > - > - result = confdb_finalize (handle); > - printf ("Finalize result is %d (should be 1)\n", result); > - return (0); > -} > diff --git a/tools/Makefile.am b/tools/Makefile.am > index 425a1b1..c74af0f 100644 > --- a/tools/Makefile.am > +++ b/tools/Makefile.am > @@ -34,7 +34,7 @@ INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ > -I$(top_builddir)/include/corosync > > sbin_PROGRAMS = corosync-fplay corosync-cfgtool \ > - corosync-keygen corosync-objctl \ > + corosync-keygen \ > corosync-pload corosync-cpgtool corosync-quorumtool \ > corosync-notifyd corosync-cmapctl > > @@ -45,9 +45,7 @@ EXTRA_DIST = $(bin_SCRIPTS) corosync-notifyd.sysconfig.example > corosync_fplay_LDADD = $(LIBQB_LIBS) > corosync_pload_LDADD = -lpload $(LIBQB_LIBS) > corosync_pload_LDFLAGS = -L../lib > -corosync_objctl_LDADD = -lconfdb ../lcr/liblcr.a $(LIBQB_LIBS) > -corosync_objctl_LDFLAGS = -L../lib > -corosync_cmapctl_LDADD = -lcmap $(LIBQB_LIBS) > +corosync_cmapctl_LDADD = -lcmap $(LIBQB_LIBS) > corosync_cmapctl_LDFLAGS= -L../lib > corosync_cfgtool_LDADD = -lcfg $(LIBQB_LIBS) > corosync_cfgtool_LDFLAGS= -L../lib > diff --git a/tools/corosync-objctl.c b/tools/corosync-objctl.c > deleted file mode 100644 > index bf268aa..0000000 > --- a/tools/corosync-objctl.c > +++ /dev/null > @@ -1,935 +0,0 @@ > -/* > - * Copyright (c) 2008 Allied Telesis Labs NZ > - * > - * All rights reserved. > - * > - * Author: Angus Salkeld <angus.salkeld@xxxxxxxxxxxxxxxxxxx> > - * > - * 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 <config.h> > - > -#include <sys/select.h> > -#include <stdio.h> > -#include <stdlib.h> > -#include <errno.h> > -#include <unistd.h> > -#include <string.h> > -#include <ctype.h> > -#include <sys/types.h> > -#include <sys/un.h> > - > -#include "../lib/util.h" > -#include <corosync/corotypes.h> > -#include <corosync/confdb.h> > - > -#define SEPERATOR '.' > -#define SEPERATOR_STR "." > -#define OBJ_NAME_SIZE 512 > - > - > -typedef enum { > - ACTION_READ, > - ACTION_WRITE, > - ACTION_CREATE, > - ACTION_CREATE_KEY, > - ACTION_DELETE, > - ACTION_PRINT_ALL, > - ACTION_PRINT_DEFAULT, > - ACTION_TRACK, > -} action_types_t; > - > -typedef enum { > - FIND_OBJECT_ONLY, > - FIND_OBJECT_OR_KEY, > - FIND_KEY_ONLY > -} find_object_of_type_t; > - > -static void tail_key_changed(confdb_handle_t handle, > - confdb_change_type_t change_type, > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *object_name, > - size_t object_name_len, > - const void *key_name, > - size_t key_name_len, > - const void *key_value, > - size_t key_value_len); > - > -static void tail_object_created(confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *name_pt, > - size_t name_len); > - > -static void tail_object_deleted(confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *name_pt, > - size_t name_len); > - > -static void create_object(confdb_handle_t handle, char * name_pt); > -static void create_object_key(confdb_handle_t handle, char * name_pt); > -static void write_key(confdb_handle_t handle, char * path_pt); > -static void get_parent_name(const char * name_pt, char * parent_name); > - > -static confdb_callbacks_t callbacks = { > - .confdb_key_change_notify_fn = tail_key_changed, > - .confdb_object_create_change_notify_fn = tail_object_created, > - .confdb_object_delete_change_notify_fn = tail_object_deleted, > -}; > - > -static int debug = 0; > -static int show_binary = 0; > -static int action; > - > -static void print_binary_key (char *value, size_t value_len) > -{ > - size_t i; > - char c; > - > - for (i = 0; i < value_len; i++) { > - c = value[i]; > - if (c >= ' ' && c < 0x7f && c != '\\') { > - fputc (c, stdout); > - } else { > - if (c == '\\') { > - printf ("\\\\"); > - } else { > - printf ("\\x%02X", c); > - } > - } > - } > - printf ("\n"); > -} > - > -static void print_key (char *key_name, void *value, size_t value_len, confdb_value_types_t type) > -{ > - switch (type) { > - case CONFDB_VALUETYPE_INT16: > - printf ("%s=%hd\n", key_name, > - *(int16_t*)value); > - break; > - case CONFDB_VALUETYPE_UINT16: > - printf ("%s=%hu\n", key_name, > - *(uint16_t*)value); > - break; > - case CONFDB_VALUETYPE_INT32: > - printf ("%s=%d\n", key_name, > - *(int32_t*)value); > - break; > - case CONFDB_VALUETYPE_UINT32: > - printf ("%s=%u\n", key_name, > - *(uint32_t*)value); > - break; > - case CONFDB_VALUETYPE_INT64: > - printf ("%s=%"PRIi64"\n", key_name, > - *(int64_t*)value); > - break; > - case CONFDB_VALUETYPE_UINT64: > - printf ("%s=%"PRIu64"\n", key_name, > - *(uint64_t*)value); > - break; > - case CONFDB_VALUETYPE_FLOAT: > - printf ("%s=%f\n", key_name, > - *(float*)value); > - break; > - case CONFDB_VALUETYPE_DOUBLE: > - printf ("%s=%f\n", key_name, > - *(double*)value); > - break; > - case CONFDB_VALUETYPE_STRING: > - printf ("%s=%s\n", key_name, (char*)value); > - break; > - default: > - case CONFDB_VALUETYPE_ANY: > - if (!show_binary) { > - printf ("%s=**binary**(%d)\n", key_name, type); > - } else { > - printf ("%s=", key_name); > - print_binary_key ((char *)value, value_len); > - } > - break; > - } > -} > - > -/* Recursively dump the object tree */ > -static void print_config_tree(confdb_handle_t handle, hdb_handle_t parent_object_handle, char * parent_name) > -{ > - hdb_handle_t object_handle; > - char object_name[OBJ_NAME_SIZE]; > - size_t object_name_len; > - char key_name[OBJ_NAME_SIZE]; > - char key_value[OBJ_NAME_SIZE]; > - size_t key_value_len; > - cs_error_t res; > - int children_printed; > - confdb_value_types_t type; > - > - /* Show the keys */ > - res = confdb_key_iter_start(handle, parent_object_handle); > - if (res != CS_OK) { > - fprintf(stderr, "error resetting key iterator for object "HDB_X_FORMAT" %s\n", > - parent_object_handle, cs_strerror(res)); > - exit(EXIT_FAILURE); > - } > - children_printed = 0; > - > - while ( (res = confdb_key_iter_typed(handle, > - parent_object_handle, > - key_name, > - key_value, > - &key_value_len, > - &type)) == CS_OK) { > - key_value[key_value_len] = '\0'; > - if (parent_name != NULL) > - printf("%s%c", parent_name, SEPERATOR); > - > - print_key(key_name, key_value, key_value_len, type); > - > - children_printed++; > - } > - > - /* Show sub-objects */ > - res = confdb_object_iter_start(handle, parent_object_handle); > - if (res != CS_OK) { > - fprintf(stderr, "error resetting object iterator for "HDB_X_FORMAT" %s\n", > - parent_object_handle, cs_strerror(res)); > - exit(EXIT_FAILURE); > - } > - > - while ( (res = confdb_object_iter(handle, > - parent_object_handle, > - &object_handle, > - object_name, > - &object_name_len)) == CS_OK) { > - > - object_name[object_name_len] = '\0'; > - if (parent_name != NULL) { > - snprintf(key_value, OBJ_NAME_SIZE, "%s%c%s", parent_name, SEPERATOR, object_name); > - } else { > - if ((action == ACTION_PRINT_DEFAULT) && strcmp(object_name, "internal_configuration") == 0) continue; > - snprintf(key_value, OBJ_NAME_SIZE, "%s", object_name); > - } > - print_config_tree(handle, object_handle, key_value); > - children_printed++; > - } > - if (children_printed == 0 && parent_name != NULL) { > - printf("%s\n", parent_name); > - } > -} > - > -static int read_in_config_file (char * filename) > -{ > - confdb_handle_t handle; > - int result; > - int ignore; > - int c; > - FILE* fh; > - char buf[1024]; > - char * line; > - char * end; > - char parent_name[OBJ_NAME_SIZE]; > - > - if (access (filename, R_OK) != 0) { > - perror ("Couldn't access file."); > - return -1; > - } > - > - fh = fopen(filename, "r"); > - if (fh == NULL) { > - perror ("Couldn't open file."); > - return -1; > - } > - result = confdb_initialize (&handle, &callbacks); > - if (result != CONFDB_OK) { > - fprintf (stderr, "Could not initialize objdb library. Error %d\n", result); > - fclose (fh); > - return -1; > - } > - > - while (fgets (buf, 1024, fh) != NULL) { > - /* find the first real character, if it is > - * a '#' then ignore this line. > - * else process. > - * if no real characters then also ignore. > - */ > - ignore = 1; > - for (c = 0; c < 1024; c++) { > - if (isblank (buf[c])) > - continue; > - > - if (buf[c] == '#' || buf[c] == '\n') { > - ignore = 1; > - break; > - } > - ignore = 0; > - line = &buf[c]; > - break; > - } > - if (ignore == 1) > - continue; > - > - /* kill the \n */ > - end = strchr (line, '\n'); > - if (end != NULL) > - *end = '\0'; > - > - if (debug == 2) > - printf ("%d: %s\n", __LINE__, line); > - > - /* find the parent object */ > - get_parent_name(line, parent_name); > - > - if (debug == 2) > - printf ("%d: %s\n", __LINE__, parent_name); > - > - /* create the object */ > - create_object (handle, parent_name); > - /* write the attribute */ > - write_key (handle, line); > - } > - > - confdb_finalize (handle); > - fclose (fh); > - return 0; > -} > - > -static int print_all(void) > -{ > - confdb_handle_t handle; > - int result; > - > - result = confdb_initialize (&handle, &callbacks); > - if (result != CS_OK) { > - fprintf (stderr, "Could not initialize objdb library: %s\n", > - cs_strerror(result)); > - return 1; > - } > - > - print_config_tree(handle, OBJECT_PARENT_HANDLE, NULL); > - > - result = confdb_finalize (handle); > - > - return 0; > -} > - > - > -static int print_help(void) > -{ > - printf("\n"); > - printf ("usage: corosync-objctl [-b] object%ckey ... Print an object\n", SEPERATOR); > - printf (" corosync-objctl -c object%cchild_obj ... Create Object\n", SEPERATOR); > - printf (" corosync-objctl -d object%cchild_obj ... Delete object\n", SEPERATOR); > - printf (" corosync-objctl -w object%cchild_obj.key=value ... Create a key\n", SEPERATOR); > - printf (" corosync-objctl -n object%cchild_obj.key=value ... Create a new object with the key\n", SEPERATOR); > - printf (" corosync-objctl -t object%cchild_obj ... Track changes\n", SEPERATOR); > - printf (" corosync-objctl [-b] -a Print all objects\n"); > - printf (" corosync-objctl -p <filename> Load in config from the specified file.\n"); > - printf("\n"); > - return 0; > -} > - > -static cs_error_t validate_name(char * obj_name_pt) > -{ > - if ((strchr (obj_name_pt, SEPERATOR) == NULL) && > - (strchr (obj_name_pt, '=') == NULL)) > - return CS_OK; > - else > - return CS_ERR_INVALID_PARAM; > -} > - > -static void get_parent_name(const char * name_pt, char * parent_name) > -{ > - char * tmp; > - strcpy(parent_name, name_pt); > - > - /* first remove the value (it could be a file path */ > - tmp = strchr(parent_name, '='); > - if (tmp != NULL) { > - *tmp = '\0'; > - tmp--; > - while (isblank (*tmp)) { > - *tmp = '\0'; > - tmp--; > - } > - } > - > - /* then truncate the child name */ > - tmp = strrchr(parent_name, SEPERATOR); > - if (tmp != NULL) *tmp = '\0'; > -} > - > -static void get_key(const char * name_pt, char * key_name, char * key_value) > -{ > - char * tmp = (char*)name_pt; > - char str_copy[OBJ_NAME_SIZE]; > - char * copy_tmp = str_copy; > - int equals_seen = 0; > - int in_quotes = 0; > - > - /* strip out spaces when not in quotes */ > - while (*tmp != '\0') { > - if (*tmp == '=') > - equals_seen = 1; > - if (equals_seen && *tmp == '"') { > - if (in_quotes) > - in_quotes = 0; > - else > - in_quotes = 1; > - } > - if (*tmp != ' ' || in_quotes) { > - *copy_tmp = *tmp; > - copy_tmp++; > - } > - tmp++; > - } > - *copy_tmp = '\0'; > - > - /* first remove the value (it could have a SEPERATOR in it */ > - tmp = strchr(str_copy, '='); > - if (tmp != NULL && strlen(tmp) > 0) { > - strcpy(key_value, tmp+1); > - *tmp = '\0'; > - } else { > - key_value[0] = '\0'; > - } > - /* then remove the name */ > - tmp = strrchr(str_copy, SEPERATOR); > - if (tmp == NULL) tmp = str_copy; > - strcpy(key_name, tmp+1); > -} > - > -static cs_error_t find_object (confdb_handle_t handle, > - char * name_pt, > - find_object_of_type_t type, > - hdb_handle_t * out_handle) > -{ > - char * obj_name_pt; > - char * save_pt; > - hdb_handle_t obj_handle; > - confdb_handle_t parent_object_handle = OBJECT_PARENT_HANDLE; > - char tmp_name[OBJ_NAME_SIZE]; > - cs_error_t res = CS_OK; > - > - strncpy (tmp_name, name_pt, sizeof (tmp_name)); > - tmp_name[sizeof (tmp_name) - 1] = '\0'; > - obj_name_pt = strtok_r(tmp_name, SEPERATOR_STR, &save_pt); > - > - while (obj_name_pt != NULL) { > - res = confdb_object_find_start(handle, parent_object_handle); > - if (res != CS_OK) { > - fprintf (stderr, "Could not start object_find %s\n", > - cs_strerror(res)); > - exit (EXIT_FAILURE); > - } > - > - res = confdb_object_find(handle, parent_object_handle, > - obj_name_pt, strlen (obj_name_pt), &obj_handle); > - if (res != CS_OK) { > - return res; > - } > - > - parent_object_handle = obj_handle; > - obj_name_pt = strtok_r (NULL, SEPERATOR_STR, &save_pt); > - } > - > - *out_handle = parent_object_handle; > - return res; > -} > - > -static void read_object(confdb_handle_t handle, char * name_pt) > -{ > - char parent_name[OBJ_NAME_SIZE]; > - hdb_handle_t obj_handle; > - cs_error_t res; > - > - get_parent_name(name_pt, parent_name); > - res = find_object (handle, name_pt, FIND_OBJECT_OR_KEY, &obj_handle); > - if (res == CS_OK) { > - print_config_tree(handle, obj_handle, parent_name); > - } > -} > - > -static void write_key(confdb_handle_t handle, char * path_pt) > -{ > - hdb_handle_t obj_handle; > - char parent_name[OBJ_NAME_SIZE]; > - char key_name[OBJ_NAME_SIZE]; > - char key_value[OBJ_NAME_SIZE]; > - char old_key_value[OBJ_NAME_SIZE]; > - size_t old_key_value_len; > - cs_error_t res; > - confdb_value_types_t type; > - > - /* find the parent object */ > - get_parent_name(path_pt, parent_name); > - get_key(path_pt, key_name, key_value); > - > - if (debug == 1) > - printf ("%d: key:\"%s\", value:\"%s\"\n", > - __LINE__, key_name, key_value); > - > - if (validate_name(key_name) != CS_OK) { > - fprintf(stderr, "Incorrect key name, can not have \"=\" or \"%c\"\n", SEPERATOR); > - exit(EXIT_FAILURE); > - } > - res = find_object (handle, parent_name, FIND_OBJECT_ONLY, &obj_handle); > - > - if (res != CS_OK) { > - fprintf(stderr, "Can't find parent object of \"%s\"\n", path_pt); > - exit(EXIT_FAILURE); > - } > - > - /* get the current key */ > - res = confdb_key_get_typed (handle, > - obj_handle, > - key_name, > - old_key_value, > - &old_key_value_len, &type); > - > - if (res == CS_OK) { > - /* replace the current value */ > - res = confdb_key_replace (handle, > - obj_handle, > - key_name, > - strlen(key_name), > - old_key_value, > - old_key_value_len, > - key_value, > - strlen(key_value)); > - > - if (res != CS_OK) > - fprintf(stderr, "Failed to replace the key %s=%s. Error %s\n", > - key_name, key_value, cs_strerror(res)); > - } else { > - /* not there, create a new key */ > - res = confdb_key_create_typed (handle, > - obj_handle, > - key_name, > - key_value, > - strlen(key_value), > - CONFDB_VALUETYPE_STRING); > - if (res != CS_OK) > - fprintf(stderr, "Failed to create the key %s=%s. Error %s\n", > - key_name, key_value, cs_strerror(res)); > - } > - > -} > - > -static void create_object(confdb_handle_t handle, char * name_pt) > -{ > - char * obj_name_pt; > - char * save_pt; > - hdb_handle_t obj_handle; > - hdb_handle_t parent_object_handle = OBJECT_PARENT_HANDLE; > - char tmp_name[OBJ_NAME_SIZE]; > - cs_error_t res; > - > - strncpy (tmp_name, name_pt, sizeof (tmp_name)); > - tmp_name[sizeof (tmp_name) - 1] = '\0'; > - obj_name_pt = strtok_r(tmp_name, SEPERATOR_STR, &save_pt); > - > - while (obj_name_pt != NULL) { > - res = confdb_object_find_start(handle, parent_object_handle); > - if (res != CS_OK) { > - fprintf (stderr, "Could not start object_find %s\n", > - cs_strerror(res)); > - exit (EXIT_FAILURE); > - } > - > - res = confdb_object_find(handle, parent_object_handle, > - obj_name_pt, strlen (obj_name_pt), &obj_handle); > - if (res != CS_OK) { > - > - if (validate_name(obj_name_pt) != CS_OK) { > - fprintf(stderr, "Incorrect object name \"%s\", \"=\" not allowed.\n", > - obj_name_pt); > - exit(EXIT_FAILURE); > - } > - > - if (debug) > - printf ("%s:%d: %s\n", __func__,__LINE__, obj_name_pt); > - res = confdb_object_create (handle, > - parent_object_handle, > - obj_name_pt, > - strlen (obj_name_pt), > - &obj_handle); > - if (res != CS_OK) > - fprintf(stderr, "Failed to create object \"%s\". Error %s.\n", > - obj_name_pt, cs_strerror(res)); > - } > - > - parent_object_handle = obj_handle; > - obj_name_pt = strtok_r (NULL, SEPERATOR_STR, &save_pt); > - } > -} > - > -static void create_object_key(confdb_handle_t handle, char *name_pt) > -{ > - char * obj_name_pt; > - char * new_obj_name_pt; > - char * save_pt; > - hdb_handle_t obj_handle; > - hdb_handle_t parent_object_handle = OBJECT_PARENT_HANDLE; > - char tmp_name[OBJ_NAME_SIZE]; > - cs_error_t res; > - char parent_name[OBJ_NAME_SIZE]; > - char key_name[OBJ_NAME_SIZE]; > - char key_value[OBJ_NAME_SIZE]; > - > - get_parent_name(name_pt, parent_name); > - get_key(name_pt, key_name, key_value); > - > - strncpy (tmp_name, parent_name, sizeof (tmp_name)); > - tmp_name[sizeof (tmp_name) - 1] = '\0'; > - obj_name_pt = strtok_r(tmp_name, SEPERATOR_STR, &save_pt); > - > - /* > - * Create parent object tree > - */ > - while (obj_name_pt != NULL) { > - res = confdb_object_find_start(handle, parent_object_handle); > - if (res != CS_OK) { > - fprintf (stderr, "Could not start object_find %d\n", res); > - exit (EXIT_FAILURE); > - } > - > - new_obj_name_pt = strtok_r (NULL, SEPERATOR_STR, &save_pt); > - res = confdb_object_find(handle, parent_object_handle, > - obj_name_pt, strlen (obj_name_pt), &obj_handle); > - if (res != CS_OK || new_obj_name_pt == NULL) { > - > - if (validate_name(obj_name_pt) != CS_OK) { > - fprintf(stderr, "Incorrect object name \"%s\", \"=\" not allowed.\n", > - obj_name_pt); > - exit(EXIT_FAILURE); > - } > - > - if (debug) > - printf ("%s:%d: %s\n", __func__,__LINE__, obj_name_pt); > - res = confdb_object_create (handle, > - parent_object_handle, > - obj_name_pt, > - strlen (obj_name_pt), > - &obj_handle); > - if (res != CS_OK) { > - fprintf(stderr, "Failed to create object \"%s\". Error %d.\n", > - obj_name_pt, res); > - } > - } > - parent_object_handle = obj_handle; > - obj_name_pt = new_obj_name_pt; > - } > - > - /* > - * Create key > - */ > - res = confdb_key_create_typed (handle, > - obj_handle, > - key_name, > - key_value, > - strlen(key_value), > - CONFDB_VALUETYPE_STRING); > - if (res != CS_OK) { > - fprintf(stderr, > - "Failed to create the key %s=%s. Error %d\n", > - key_name, key_value, res); > - } > -} > - > -/* Print "?" in place of any non-printable byte of OBJ. */ > -static void print_name (FILE *fp, const void *obj, size_t obj_len) > -{ > - const char *p = obj; > - size_t i; > - for (i = 0; i < obj_len; i++) { > - int c = *p++; > - if (!isprint (c)) { > - c = '?'; > - } > - fputc (c, fp); > - } > -} > - > -static void tail_key_changed(confdb_handle_t handle, > - confdb_change_type_t change_type, > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *object_name_pt, > - size_t object_name_len, > - const void *key_name_pt, > - size_t key_name_len, > - const void *key_value_pt, > - size_t key_value_len) > -{ > - /* printf("key_changed> %.*s.%.*s=%.*s\n", */ > - fputs("key_changed> ", stdout); > - print_name (stdout, object_name_pt, object_name_len); > - fputs(".", stdout); > - print_name (stdout, key_name_pt, key_name_len); > - fputs("=", stdout); > - print_name (stdout, key_value_pt, key_value_len); > - fputs("\n", stdout); > -} > - > -static void tail_object_created(confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - hdb_handle_t object_handle, > - const void *name_pt, > - size_t name_len) > -{ > - fputs("object_created>", stdout); > - print_name(stdout, name_pt, name_len); > - fputs("\n", stdout); > -} > - > -static void tail_object_deleted(confdb_handle_t handle, > - hdb_handle_t parent_object_handle, > - const void *name_pt, > - size_t name_len) > -{ > - fputs("object_deleted>", stdout); > - print_name(stdout, name_pt, name_len); > - fputs("\n", stdout); > -} > - > -static void listen_for_object_changes(confdb_handle_t handle) > -{ > - int result; > - fd_set read_fds; > - int select_fd; > - int quit = CS_FALSE; > - > - FD_ZERO (&read_fds); > - if (confdb_fd_get (handle, &select_fd) != CS_OK) { > - printf ("can't get the confdb selector object.\n"); > - return; > - } > - printf ("Type \"q\" to finish\n"); > - 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)) { > - char inbuf[3]; > - > - if (fgets(inbuf, sizeof(inbuf), stdin) == NULL) > - quit = CS_TRUE; > - else if (strncmp(inbuf, "q", 1) == 0) > - quit = CS_TRUE; > - } > - if (FD_ISSET (select_fd, &read_fds)) { > - if (confdb_dispatch (handle, CONFDB_DISPATCH_ALL) != CS_OK) > - exit(1); > - } > - } while (result && quit == CS_FALSE); > - > - (void)confdb_stop_track_changes(handle); > - > -} > - > -static void track_object(confdb_handle_t handle, char * name_pt) > -{ > - cs_error_t res; > - hdb_handle_t obj_handle; > - > - res = find_object (handle, name_pt, FIND_OBJECT_ONLY, &obj_handle); > - > - if (res != CS_OK) { > - fprintf (stderr, "Could not find object \"%s\". Error %s\n", > - name_pt, cs_strerror(res)); > - return; > - } > - > - res = confdb_track_changes (handle, obj_handle, CONFDB_TRACK_DEPTH_RECURSIVE); > - if (res != CS_OK) { > - fprintf (stderr, "Could not enable tracking on object \"%s\". Error %s\n", > - name_pt, cs_strerror(res)); > - return; > - } > -} > - > -static void stop_tracking(confdb_handle_t handle) > -{ > - cs_error_t res; > - > - res = confdb_stop_track_changes (handle); > - if (res != CS_OK) { > - fprintf (stderr, "Could not stop tracking. Error %s\n", > - cs_strerror(res)); > - return; > - } > -} > - > -static void delete_object(confdb_handle_t handle, char * name_pt) > -{ > - cs_error_t res; > - hdb_handle_t obj_handle; > - res = find_object (handle, name_pt, FIND_OBJECT_ONLY, &obj_handle); > - > - if (res == CS_OK) { > - res = confdb_object_destroy (handle, obj_handle); > - > - if (res != CS_OK) > - fprintf(stderr, "Failed to find object \"%s\" to delete. \n Error %s\n", > - name_pt, cs_strerror(res)); > - } else { > - char parent_name[OBJ_NAME_SIZE]; > - char key_name[OBJ_NAME_SIZE]; > - char key_value[OBJ_NAME_SIZE]; > - > - /* find the parent object */ > - get_parent_name(name_pt, parent_name); > - get_key(name_pt, key_name, key_value); > - res = find_object (handle, parent_name, FIND_OBJECT_ONLY, &obj_handle); > - > - if (res != CS_OK) { > - fprintf(stderr, "Failed to find the key's parent object \"%s\". Error %s\n", > - parent_name, cs_strerror(res)); > - exit (EXIT_FAILURE); > - } > - > - res = confdb_key_delete (handle, > - obj_handle, > - key_name, > - strlen(key_name), > - key_value, > - strlen(key_value)); > - > - if (res != CS_OK) > - fprintf(stderr, "Failed to delete key \"%s=%s\" from object \"%s\".\n Error %s\n", > - key_name, key_value, parent_name, cs_strerror(res)); > - } > -} > - > - > -int main (int argc, char *argv[]) { > - confdb_handle_t handle; > - cs_error_t result; > - int c; > - > - action = ACTION_READ; > - > - for (;;){ > - c = getopt (argc,argv,"habwncvdtp:"); > - if (c==-1) { > - break; > - } > - switch (c) { > - case 'v': > - debug++; > - break; > - case 'h': > - return print_help(); > - break; > - case 'a': > - action = ACTION_PRINT_ALL; > - break; > - case 'b': > - show_binary++; > - break; > - case 'p': > - return read_in_config_file (optarg); > - break; > - case 'c': > - action = ACTION_CREATE; > - break; > - case 'd': > - action = ACTION_DELETE; > - break; > - case 'w': > - action = ACTION_WRITE; > - break; > - case 'n': > - action = ACTION_CREATE_KEY; > - break; > - case 't': > - action = ACTION_TRACK; > - break; > - default : > - action = ACTION_READ; > - break; > - } > - } > - > - if (argc == 1) { > - action = ACTION_PRINT_DEFAULT; > - return print_all(); > - } else if (action == ACTION_PRINT_ALL) { > - return print_all(); > - } else if (optind >= argc) { > - fprintf(stderr, "Expected an object path after options\n"); > - exit(EXIT_FAILURE); > - } > - > - result = confdb_initialize (&handle, &callbacks); > - if (result != CS_OK) { > - fprintf (stderr, "Failed to initialize the objdb API. Error %s\n", > - cs_strerror(result)); > - exit (EXIT_FAILURE); > - } > - while (optind < argc) { > - switch (action) { > - case ACTION_READ: > - read_object(handle, argv[optind++]); > - break; > - case ACTION_WRITE: > - write_key(handle, argv[optind++]); > - break; > - case ACTION_CREATE: > - create_object(handle, argv[optind++]); > - break; > - case ACTION_CREATE_KEY: > - create_object_key(handle, argv[optind++]); > - break; > - case ACTION_DELETE: > - delete_object(handle, argv[optind++]); > - break; > - case ACTION_TRACK: > - track_object(handle, argv[optind++]); > - break; > - } > - } > - > - if (action == ACTION_TRACK) { > - listen_for_object_changes(handle); > - stop_tracking(handle); > - } > - > - result = confdb_finalize (handle); > - if (result != CS_OK) { > - fprintf (stderr, "Error finalizing objdb API.\n Error %s\n", > - cs_strerror(result)); > - exit(EXIT_FAILURE); > - } > - > - return 0; > -} _______________________________________________ discuss mailing list discuss@xxxxxxxxxxxx http://lists.corosync.org/mailman/listinfo/discuss