libqb: change ipc -> qb_ipc

IPC: return 0/-ENOBUFS from message handler
IPC: use the new rate_limit API to improve perf.
CPG: add send_async API & hook up flow control
IPC: Fix flow control getting stuck.
IPC: Port the remaining libs to use libqb IPC
IPC: remove libqb flowcontrol API
TEST: put cpg_dispatch() in it's own thread
IPC: cleanup ipc_glue.c name everything cs_ipcs_*()
IPC: add back statistics
IPC: remove coroipcc_ symbols from lib*.versions
IPC: init each se's IPC as it is loaded.
IPC: use the new connection_closed() event to free the context.
IPC: re-add zero copy functionality back
IPC: remove cpg_mcast_joined_async() and make it the default
 -> now cpg_mcast_joined() == cpg_mcast_joined_async()
libqb: expose a libqb error converter
libqb: add missing error conversions
libqb: remove repeat try loop in lib/cpg.c
CPG: fix zero copy mcast
CPG: use newer return codes
Add ENOTCONN to qb_to_cs_error()
libqb: fix error conversion from errno to cs_error_t in confdb
libqb: change errno_to_cs to qb_to_cs_error
libqb: add a cs_strerror() to get a more meaningful message
libqb: fix some confusing error conversions.
libqb: set the timeout on recv's to -1 (wait forever)

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
This commit is contained in:
Angus Salkeld 2011-08-05 12:18:43 +10:00
parent fce8a3c3b6
commit c6895faa05
76 changed files with 2377 additions and 5069 deletions

View File

@ -237,8 +237,6 @@ This package contains corosync libraries.
%{_libdir}/libevs.so.*
%{_libdir}/libtotem_pg.so.*
%{_libdir}/liblogsys.so.*
%{_libdir}/libcoroipcc.so.*
%{_libdir}/libcoroipcs.so.*
%{_libdir}/libquorum.so.*
%{_libdir}/libvotequorum.so.*
%{_libdir}/libpload.so.*
@ -266,9 +264,6 @@ The Corosync Cluster Engine APIs.
%dir %{_includedir}/corosync/
%{_includedir}/corosync/cs_config.h
%{_includedir}/corosync/corodefs.h
%{_includedir}/corosync/coroipc_types.h
%{_includedir}/corosync/coroipcs.h
%{_includedir}/corosync/coroipcc.h
%{_includedir}/corosync/cfg.h
%{_includedir}/corosync/confdb.h
%{_includedir}/corosync/corotypes.h
@ -301,8 +296,6 @@ The Corosync Cluster Engine APIs.
%{_libdir}/libevs.so
%{_libdir}/libtotem_pg.so
%{_libdir}/liblogsys.so
%{_libdir}/libcoroipcc.so
%{_libdir}/libcoroipcs.so
%{_libdir}/libquorum.so
%{_libdir}/libvotequorum.so
%{_libdir}/libpload.so
@ -318,7 +311,6 @@ The Corosync Cluster Engine APIs.
%{_mandir}/man8/confdb_overview.8*
%{_mandir}/man8/logsys_overview.8*
%{_mandir}/man8/votequorum_overview.8*
%{_mandir}/man8/coroipc_overview.8*
%{_mandir}/man8/sam_overview.8*
%changelog

View File

@ -58,19 +58,19 @@ endif
noinst_HEADERS = common_test_agent.h
cpg_test_agent_SOURCES = cpg_test_agent.c common_test_agent.c
cpg_test_agent_LDADD = -lcpg -lcfg -lcoroipcc ../../exec/crypto.o $(LIBQB_LIBS)
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 -lcoroipcc $(LIBQB_LIBS)
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 -lcoroipcc -lconfdb $(LIBQB_LIBS)
sam_test_agent_LDADD = -lsam -lquorum -lconfdb $(LIBQB_LIBS)
sam_test_agent_LDFLAGS = -L../../lib
votequorum_test_agent_SOURCES = votequorum_test_agent.c common_test_agent.c
votequorum_test_agent_LDADD = -lvotequorum -lquorum -lcoroipcc $(LIBQB_LIBS)
votequorum_test_agent_LDADD = -lvotequorum -lquorum $(LIBQB_LIBS)
votequorum_test_agent_LDFLAGS = -L../../lib
if BUILD_DARWIN

View File

@ -92,7 +92,7 @@ static struct list_head msg_log_head;
static pid_t my_pid;
static uint32_t my_nodeid;
static int32_t my_seq;
static int32_t use_zcb = 0;
static int32_t use_zcb = QB_FALSE;
static int32_t my_msgs_to_send;
static int32_t total_stored_msgs = 0;
static int32_t in_cnchg = 0;
@ -332,8 +332,6 @@ static void send_some_more_messages_later (void)
&more_messages_timer_handle);
}
static void send_some_more_messages_zcb (void)
{
msg_t *my_msg;
@ -399,7 +397,6 @@ free_buffer:
cpg_zcb_free (cpg_handle, zcb_buffer);
}
#define cs_repeat(counter, max, code) do { \
code; \
if(res == CS_ERR_TRY_AGAIN) { \
@ -490,7 +487,7 @@ static void send_some_more_messages_normal (void)
static void send_some_more_messages (void * unused)
{
if (use_zcb) {
send_some_more_messages_zcb ();
// send_some_more_messages_zcb ();
} else {
send_some_more_messages_normal ();
}
@ -502,7 +499,7 @@ static void msg_blaster (int sock, char* num_to_send_str)
my_seq = 1;
my_pid = getpid();
use_zcb = 0;
use_zcb = QB_FALSE;
total_stored_msgs = 0;
cpg_local_get (cpg_handle, &my_nodeid);
@ -539,7 +536,7 @@ static void msg_blaster_zcb (int sock, char* num_to_send_str)
my_seq = 1;
my_pid = getpid();
use_zcb = 1;
use_zcb = QB_TRUE;
total_stored_msgs = 0;
cpg_local_get (cpg_handle, &my_nodeid);

View File

@ -53,7 +53,7 @@
#include <corosync/swab.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <qb/qbipc_common.h>
#include <corosync/corodefs.h>
#include <corosync/lcr/lcr_comp.h>
#include <corosync/mar_gen.h>
@ -61,8 +61,6 @@
#include <corosync/list.h>
#include <corosync/engine/logsys.h>
#include "../exec/tlist.h"
LOGSYS_DECLARE_SUBSYS ("TST2");
/*

View File

@ -43,29 +43,25 @@ TOTEM_SRC += totemiba.c
endif
LOGSYS_SRC = wthread.c logsys.c
COROIPCS_SRC = coroipcs.c
LCRSO_SRC = objdb.c vsf_ykd.c coroparse.c vsf_quorum.c
LCRSO_OBJS = $(LCRSO_SRC:%.c=%.o)
LCRSO = $(LCRSO_SRC:%.c=%.lcrso)
lib_LIBRARIES = libtotem_pg.a liblogsys.a libcoroipcs.a
lib_LIBRARIES = libtotem_pg.a liblogsys.a
sbin_PROGRAMS = corosync
libtotem_pg_a_SOURCES = $(TOTEM_SRC)
liblogsys_a_SOURCES = $(LOGSYS_SRC)
libcoroipcs_a_SOURCES = $(COROIPCS_SRC)
corosync_SOURCES = main.c util.c sync.c apidef.c service.c \
corosync_SOURCES = main.c ipc_glue.c util.c sync.c apidef.c service.c \
timer.c totemconfig.c mainconfig.c quorum.c schedwrk.c \
../lcr/lcr_ifact.c evil.c syncv2.c
corosync_LDADD = -ltotem_pg -llogsys -lcoroipcs $(statgrab_LIBS) $(LIBQB_LIBS)
corosync_DEPENDENCIES = libtotem_pg.so.$(SONAME) liblogsys.so.$(SONAME) libcoroipcs.so.$(SONAME)
corosync_LDADD = -ltotem_pg -llogsys $(LIBQB_LIBS) $(statgrab_LIBS)
corosync_DEPENDENCIES = libtotem_pg.so.$(SONAME) liblogsys.so.$(SONAME)
corosync_LDFLAGS = $(OS_DYFLAGS) -L./
TOTEM_OBJS = $(TOTEM_SRC:%.c=%.o)
LOGSYS_OBJS = $(LOGSYS_SRC:%.c=%.o)
COROIPCS_OBJS = $(COROIPCS_SRC:%.c=%.o)
SHARED_LIBS = $(lib_LIBRARIES:%.a=%.so.$(SONAME))
SHARED_LIBS_SO = $(SHARED_LIBS:%.so.$(SONAME)=%.so)
@ -93,11 +89,6 @@ liblogsys.so.$(SONAME): $(LOGSYS_OBJS)
ln -sf liblogsys.so.$(SONAME) liblogsys.so
ln -sf liblogsys.so.$(SONAME) liblogsys.so.$(SOMAJOR)
libcoroipcs.so.$(SONAME): $(COROIPCS_OBJS)
$(CC) $(LDFLAGS) $(DARWIN_OPTS) $(COROIPCS_OBJS) -o $@ -lpthread
ln -sf libcoroipcs.so.$(SONAME) libcoroipcs.so
ln -sf libcoroipcs.so.$(SONAME) libcoroipcs.so.$(SOMAJOR)
else
if BUILD_SOLARIS
@ -114,11 +105,6 @@ liblogsys.so.$(SONAME): $(LOGSYS_OBJS)
ln -sf liblogsys.so.$(SONAME) liblogsys.so
ln -sf liblogsys.so.$(SONAME) liblogsys.so.$(SOMAJOR)
libcoroipcs.so.$(SONAME): $(COROIPCS_OBJS)
$(LD) $(LDFLAGS) -G $(COROIPCS_OBJS) -o $@ -lpthread
ln -sf libcoroipcs.so.$(SONAME) libcoroipcs.so
ln -sf libcoroipcs.so.$(SONAME) libcoroipcs.so.$(SOMAJOR)
else
%.lcrso: %.o
@ -138,13 +124,6 @@ liblogsys.so.$(SONAME): $(LOGSYS_OBJS)
ln -sf liblogsys.so.$(SONAME) liblogsys.so
ln -sf liblogsys.so.$(SONAME) liblogsys.so.$(SOMAJOR)
libcoroipcs.so.$(SONAME): $(COROIPCS_OBJS)
$(CC) -shared -o $@ \
-Wl,-soname=libcoroipcs.so.$(SOMAJOR) \
$(LDFLAGS) $^ -lpthread
ln -sf libcoroipcs.so.$(SONAME) libcoroipcs.so
ln -sf libcoroipcs.so.$(SONAME) libcoroipcs.so.$(SOMAJOR)
endif
endif

View File

@ -38,13 +38,12 @@
#include <string.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <corosync/lcr/lcr_ifact.h>
#include <corosync/totem/totempg.h>
#include <corosync/totem/totemip.h>
#include <corosync/totem/totem.h>
#include <corosync/engine/logsys.h>
#include <corosync/coroipcs.h>
#include <qb/qbipcs.h>
#include "util.h"
#include "timer.h"
#include "sync.h"
@ -101,13 +100,13 @@ static struct corosync_api_v1 apidef_corosync_api_v1 = {
.timer_expire_time_get = corosync_timer_expire_time_get,
.ipc_source_set = message_source_set,
.ipc_source_is_local = message_source_is_local,
.ipc_private_data_get = coroipcs_private_data_get,
.ipc_response_iov_send = coroipcs_response_iov_send,
.ipc_response_send = coroipcs_response_send,
.ipc_dispatch_send = coroipcs_dispatch_send,
.ipc_dispatch_iov_send = coroipcs_dispatch_iov_send,
.ipc_refcnt_inc = coroipcs_refcount_inc,
.ipc_refcnt_dec = coroipcs_refcount_dec,
.ipc_private_data_get = cs_ipcs_private_data_get,
.ipc_response_iov_send = cs_ipcs_response_iov_send,
.ipc_response_send = cs_ipcs_response_send,
.ipc_dispatch_send = cs_ipcs_dispatch_send,
.ipc_dispatch_iov_send = cs_ipcs_dispatch_iov_send,
.ipc_refcnt_inc = cs_ipc_refcnt_inc,
.ipc_refcnt_dec = cs_ipc_refcnt_dec,
.totem_nodeid_get = totempg_my_nodeid_get,
.totem_family_get = totempg_my_family_get,
.totem_ring_reenable = totempg_ring_reenable,

File diff suppressed because it is too large Load Diff

View File

@ -231,6 +231,7 @@ static int parser_check_item_uidgid(struct objdb_iface_ver0 *objdb,
return 1;
}
static int read_uidgid_files_into_objdb(
struct objdb_iface_ver0 *objdb,
const char **error_string)

View File

@ -67,7 +67,6 @@
#include <corosync/totem/totempg.h>
#include <corosync/swab.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <corosync/corodefs.h>
#include <corosync/list.h>
#include <corosync/lcr/lcr_ifact.h>
@ -75,7 +74,7 @@
#include <corosync/engine/config.h>
#include <corosync/engine/coroapi.h>
#include <corosync/engine/logsys.h>
#include <corosync/coroipcs.h>
#include <qb/qbipcs.h>
#include "sync.h"
#include "evil.h"
@ -255,11 +254,6 @@ enum clm_message_req_types {
#define SA_MAX_NAME_LENGTH 256
typedef struct {
int size __attribute__((aligned(8)));
int id __attribute__((aligned(8)));
} mar_req_header_t __attribute__((aligned(8)));
typedef enum {
MAR_CLM_AF_INET = 1,
MAR_CLM_AF_INET6 = 2
@ -296,7 +290,7 @@ typedef struct {
mar_clm_cluster_node_t my_cluster_node;
struct req_exec_clm_nodejoin {
mar_req_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_clm_cluster_node_t cluster_node __attribute__((aligned(8)));
};
@ -450,7 +444,7 @@ enum evt_message_req_types {
};
struct req_evt_chan_command {
mar_req_header_t chc_head __attribute__((aligned(8)));
struct qb_ipc_request_header chc_head __attribute__((aligned(8)));
mar_uint32_t chc_op __attribute__((aligned(8)));
};

749
exec/ipc_glue.c Normal file
View File

@ -0,0 +1,749 @@
/*
* Copyright (c) 2010 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Angus Salkeld <asalkeld@redhat.com>
*
* This software licensed under BSD license, the text of which follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of Red Hat, 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 <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <assert.h>
#include <sys/uio.h>
#include <string.h>
#include <qb/qbdefs.h>
#include <qb/qblist.h>
#include <qb/qbutil.h>
#include <qb/qbloop.h>
#include <qb/qbipcs.h>
#include <corosync/swab.h>
#include <corosync/corotypes.h>
#include <corosync/corodefs.h>
#include <corosync/totem/totempg.h>
#include <corosync/engine/objdb.h>
#include <corosync/engine/config.h>
#include <corosync/engine/logsys.h>
#include "mainconfig.h"
#include "sync.h"
#include "syncv2.h"
#include "timer.h"
#include "main.h"
#include "util.h"
#include "apidef.h"
#include "service.h"
LOGSYS_DECLARE_SUBSYS ("MAIN");
static struct corosync_api_v1 *api = NULL;
static int ipc_subsys_id = -1;
static int32_t ipc_not_enough_fds_left = 0;
static int32_t ipc_fc_is_quorate; /* boolean */
static int32_t ipc_fc_totem_queue_level; /* percentage used */
static int32_t ipc_fc_sync_in_process; /* boolean */
static qb_handle_t object_connection_handle;
struct cs_ipcs_mapper {
int32_t id;
qb_ipcs_service_t *inst;
char name[256];
};
static struct cs_ipcs_mapper ipcs_mapper[SERVICE_HANDLER_MAXIMUM_COUNT];
static int32_t cs_ipcs_job_add(enum qb_loop_priority p, void *data, qb_loop_job_dispatch_fn fn);
static int32_t cs_ipcs_dispatch_add(enum qb_loop_priority p, int32_t fd, int32_t events,
void *data, qb_ipcs_dispatch_fn_t fn);
static int32_t cs_ipcs_dispatch_mod(enum qb_loop_priority p, int32_t fd, int32_t events,
void *data, qb_ipcs_dispatch_fn_t fn);
static int32_t cs_ipcs_dispatch_del(int32_t fd);
static struct qb_ipcs_poll_handlers corosync_poll_funcs = {
.job_add = cs_ipcs_job_add,
.dispatch_add = cs_ipcs_dispatch_add,
.dispatch_mod = cs_ipcs_dispatch_mod,
.dispatch_del = cs_ipcs_dispatch_del,
};
static int32_t cs_ipcs_connection_accept (qb_ipcs_connection_t *c, uid_t euid, gid_t egid);
static void cs_ipcs_connection_created(qb_ipcs_connection_t *c);
static int32_t cs_ipcs_msg_process(qb_ipcs_connection_t *c,
void *data, size_t size);
static int32_t cs_ipcs_connection_closed (qb_ipcs_connection_t *c);
static void cs_ipcs_connection_destroyed (qb_ipcs_connection_t *c);
static struct qb_ipcs_service_handlers corosync_service_funcs = {
.connection_accept = cs_ipcs_connection_accept,
.connection_created = cs_ipcs_connection_created,
.msg_process = cs_ipcs_msg_process,
.connection_closed = cs_ipcs_connection_closed,
.connection_destroyed = cs_ipcs_connection_destroyed,
};
static const char* cs_ipcs_serv_short_name(int32_t service_id)
{
const char *name;
switch (service_id) {
case EVS_SERVICE:
name = "evs";
break;
case CLM_SERVICE:
name = "saClm";
break;
case AMF_SERVICE:
name = "saAmf";
break;
case CKPT_SERVICE:
name = "saCkpt";
break;
case EVT_SERVICE:
name = "saEvt";
break;
case LCK_SERVICE:
name = "saLck";
break;
case MSG_SERVICE:
name = "saMsg";
break;
case CFG_SERVICE:
name = "cfg";
break;
case CPG_SERVICE:
name = "cpg";
break;
case CMAN_SERVICE:
name = "cman";
break;
case PCMK_SERVICE:
name = "pacemaker.engine";
break;
case CONFDB_SERVICE:
name = "confdb";
break;
case QUORUM_SERVICE:
name = "quorum";
break;
case PLOAD_SERVICE:
name = "pload";
break;
case TMR_SERVICE:
name = "saTmr";
break;
case VOTEQUORUM_SERVICE:
name = "votequorum";
break;
case NTF_SERVICE:
name = "saNtf";
break;
case AMF_V2_SERVICE:
name = "saAmfV2";
break;
case TST_SV1_SERVICE:
name = "tst";
break;
case TST_SV2_SERVICE:
name = "tst2";
break;
case MON_SERVICE:
name = "mon";
break;
case WD_SERVICE:
name = "wd";
break;
default:
name = NULL;
break;
}
return name;
}
int32_t cs_ipcs_service_destroy(int32_t service_id)
{
qb_ipcs_destroy(ipcs_mapper[service_id].inst);
return 0;
}
static int32_t cs_ipcs_connection_accept (qb_ipcs_connection_t *c, uid_t euid, gid_t egid)
{
struct list_head *iter;
int32_t service = qb_ipcs_service_id_get(c);
if (ais_service[service] == NULL || ais_service_exiting[service]) {
return -ENOSYS;
}
if (ipc_not_enough_fds_left) {
return -EMFILE;
}
if (euid == 0 || egid == 0) {
return 0;
}
for (iter = uidgid_list_head.next; iter != &uidgid_list_head;
iter = iter->next) {
struct uidgid_item *ugi = qb_list_entry (iter, struct uidgid_item,
list);
if (euid == ugi->uid || egid == ugi->gid)
return 0;
}
log_printf(LOGSYS_LEVEL_ERROR, "Denied connection attempt from %d:%d", euid, egid);
return -EACCES;
}
static char * pid_to_name (pid_t pid, char *out_name, size_t name_len)
{
char *name;
char *rest;
FILE *fp;
char fname[32];
char buf[256];
snprintf (fname, 32, "/proc/%d/stat", pid);
fp = fopen (fname, "r");
if (!fp) {
return NULL;
}
if (fgets (buf, sizeof (buf), fp) == NULL) {
fclose (fp);
return NULL;
}
fclose (fp);
name = strrchr (buf, '(');
if (!name) {
return NULL;
}
/* move past the bracket */
name++;
rest = strrchr (buf, ')');
if (rest == NULL || rest[1] != ' ') {
return NULL;
}
*rest = '\0';
/* move past the NULL and space */
rest += 2;
/* copy the name */
strncpy (out_name, name, name_len);
out_name[name_len - 1] = '\0';
return out_name;
}
struct cs_ipcs_conn_context {
qb_handle_t stats_handle;
char data[1];
};
static void cs_ipcs_connection_created(qb_ipcs_connection_t *c)
{
int32_t service = 0;
uint32_t zero_32 = 0;
uint64_t zero_64 = 0;
unsigned int key_incr_dummy;
qb_handle_t object_handle;
struct cs_ipcs_conn_context *context;
char conn_name[42];
char proc_name[32];
struct qb_ipcs_connection_stats stats;
int32_t size = sizeof(struct cs_ipcs_conn_context);
log_printf(LOG_INFO, "%s() new connection", __func__);
service = qb_ipcs_service_id_get(c);
size += ais_service[service]->private_data_size;
context = calloc(1, size);
qb_ipcs_context_set(c, context);
ais_service[service]->lib_init_fn(c);
api->object_key_increment (object_connection_handle,
"active", strlen("active"),
&key_incr_dummy);
qb_ipcs_connection_stats_get(c, &stats, QB_FALSE);
if (stats.client_pid > 0) {
if (pid_to_name (stats.client_pid, proc_name, sizeof(proc_name))) {
snprintf (conn_name,
sizeof(conn_name),
"%s:%d:%p", proc_name,
stats.client_pid, c);
} else {
snprintf (conn_name,
sizeof(conn_name),
"%d:%p",
stats.client_pid, c);
}
} else {
snprintf (conn_name,
sizeof(conn_name),
"%p", c);
}
api->object_create (object_connection_handle,
&object_handle,
conn_name,
strlen (conn_name));
context->stats_handle = object_handle;
api->object_key_create_typed (object_handle,
"service_id",
&zero_32, sizeof (zero_32),
OBJDB_VALUETYPE_UINT32);
api->object_key_create_typed (object_handle,
"client_pid",
&zero_32, sizeof (zero_32),
OBJDB_VALUETYPE_INT32);
api->object_key_create_typed (object_handle,
"responses",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
api->object_key_create_typed (object_handle,
"dispatched",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
api->object_key_create_typed (object_handle,
"requests",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_INT64);
api->object_key_create_typed (object_handle,
"send_retries",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
api->object_key_create_typed (object_handle,
"recv_retries",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
api->object_key_create_typed (object_handle,
"flow_control",
&zero_32, sizeof (zero_32),
OBJDB_VALUETYPE_UINT32);
api->object_key_create_typed (object_handle,
"flow_control_count",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
}
void cs_ipc_refcnt_inc(void *conn)
{
qb_ipcs_connection_ref(conn);
}
void cs_ipc_refcnt_dec(void *conn)
{
qb_ipcs_connection_unref(conn);
}
void *cs_ipcs_private_data_get(void *conn)
{
struct cs_ipcs_conn_context *cnx;
cnx = qb_ipcs_context_get(conn);
return &cnx->data[0];
}
static void cs_ipcs_connection_destroyed (qb_ipcs_connection_t *c)
{
struct cs_ipcs_conn_context *cnx;
log_printf(LOG_INFO, "%s() ", __func__);
cnx = qb_ipcs_context_get(c);
if (cnx) {
free(cnx);
}
}
static int32_t cs_ipcs_connection_closed (qb_ipcs_connection_t *c)
{
struct cs_ipcs_conn_context *cnx;
unsigned int key_incr_dummy;
int32_t res = 0;
int32_t service = qb_ipcs_service_id_get(c);
log_printf(LOG_INFO, "%s() ", __func__);
res = ais_service[service]->lib_exit_fn(c);
if (res != 0) {
return res;
}
cnx = qb_ipcs_context_get(c);
api->object_destroy (cnx->stats_handle);
api->object_key_increment (object_connection_handle,
"closed", strlen("closed"),
&key_incr_dummy);
api->object_key_decrement (object_connection_handle,
"active", strlen("active"),
&key_incr_dummy);
return 0;
}
int cs_ipcs_response_iov_send (void *conn,
const struct iovec *iov,
unsigned int iov_len)
{
int32_t rc = qb_ipcs_response_sendv(conn, iov, iov_len);
if (rc >= 0) {
return 0;
}
return rc;
}
int cs_ipcs_response_send(void *conn, const void *msg, size_t mlen)
{
int32_t rc = qb_ipcs_response_send(conn, msg, mlen);
if (rc >= 0) {
return 0;
}
return rc;
}
int cs_ipcs_dispatch_send(void *conn, const void *msg, size_t mlen)
{
int32_t rc = qb_ipcs_event_send(conn, msg, mlen);
if (rc >= 0) {
return 0;
}
return rc;
}
int cs_ipcs_dispatch_iov_send (void *conn,
const struct iovec *iov,
unsigned int iov_len)
{
int32_t rc = qb_ipcs_event_sendv(conn, iov, iov_len);
if (rc >= 0) {
return 0;
}
return rc;
}
static int32_t cs_ipcs_msg_process(qb_ipcs_connection_t *c,
void *data, size_t size)
{
struct qb_ipc_response_header response;
struct qb_ipc_request_header *request_pt = (struct qb_ipc_request_header *)data;
int32_t service = qb_ipcs_service_id_get(c);
int32_t send_ok;
ssize_t res = -1;
int sending_allowed_private_data;
send_ok = corosync_sending_allowed (service,
request_pt->id,
request_pt,
&sending_allowed_private_data);
/*
* This happens when the message contains some kind of invalid
* parameter, such as an invalid size
*/
if (send_ok == -1) {
response.size = sizeof (response);
response.id = 0;
response.error = CS_ERR_INVALID_PARAM;
log_printf(LOG_INFO, "%s() invalid message! size:%d error:%d",
__func__, response.size, response.error);
qb_ipcs_response_send (c,
&response,
sizeof (response));
res = -EINVAL;
} else {
if (send_ok) {
ais_service[service]->lib_engine[request_pt->id].lib_handler_fn(c, request_pt);
res = 0;
} else {
/*
* Overload, tell library to retry
*/
response.size = sizeof (response);
response.id = 0;
response.error = CS_ERR_TRY_AGAIN;
qb_ipcs_response_send (c,
&response,
sizeof (response));
res = -ENOBUFS;
}
}
corosync_sending_allowed_release (&sending_allowed_private_data);
return res;
}
static int32_t cs_ipcs_job_add(enum qb_loop_priority p, void *data, qb_loop_job_dispatch_fn fn)
{
return qb_loop_job_add(corosync_poll_handle_get(), p, data, fn);
}
static int32_t cs_ipcs_dispatch_add(enum qb_loop_priority p, int32_t fd, int32_t events,
void *data, qb_ipcs_dispatch_fn_t fn)
{
return qb_loop_poll_add(corosync_poll_handle_get(), p, fd, events, data, fn);
}
static int32_t cs_ipcs_dispatch_mod(enum qb_loop_priority p, int32_t fd, int32_t events,
void *data, qb_ipcs_dispatch_fn_t fn)
{
return qb_loop_poll_mod(corosync_poll_handle_get(), p, fd, events, data, fn);
}
static int32_t cs_ipcs_dispatch_del(int32_t fd)
{
return qb_loop_poll_del(corosync_poll_handle_get(), fd);
}
static void cs_ipcs_low_fds_event(int32_t not_enough, int32_t fds_available)
{
ipc_not_enough_fds_left = not_enough;
if (not_enough) {
log_printf(LOGSYS_LEVEL_WARNING, "refusing new connections (fds_available:%d)\n",
fds_available);
} else {
log_printf(LOGSYS_LEVEL_NOTICE, "allowing new connections (fds_available:%d)\n",
fds_available);
}
}
int32_t cs_ipcs_q_level_get(void)
{
return ipc_fc_totem_queue_level;
}
static void cs_ipcs_check_for_flow_control(void)
{
int32_t i;
int32_t fc_enabled;
qb_loop_timer_handle tm;
for (i = 0; i < SERVICE_HANDLER_MAXIMUM_COUNT; i++) {
if (ais_service[i] == NULL) {
continue;
}
fc_enabled = QB_TRUE;
if (ipc_fc_is_quorate == 1 ||
ais_service[i]->allow_inquorate == CS_LIB_ALLOW_INQUORATE) {
/*
* we are quorate
* now check flow control
*/
if (ipc_fc_totem_queue_level != TOTEM_Q_LEVEL_CRITICAL &&
ipc_fc_sync_in_process == 0) {
fc_enabled = QB_FALSE;
}
}
if (fc_enabled) {
qb_ipcs_request_rate_limit(ipcs_mapper[i].inst, QB_IPCS_RATE_OFF);
qb_loop_timer_add(corosync_poll_handle_get(), QB_LOOP_MED, 1,
NULL, corosync_recheck_the_q_level, &tm);
} else if (ipc_fc_totem_queue_level == TOTEM_Q_LEVEL_LOW) {
qb_ipcs_request_rate_limit(ipcs_mapper[i].inst, QB_IPCS_RATE_FAST);
} else if (ipc_fc_totem_queue_level == TOTEM_Q_LEVEL_GOOD) {
qb_ipcs_request_rate_limit(ipcs_mapper[i].inst, QB_IPCS_RATE_NORMAL);
} else if (ipc_fc_totem_queue_level == TOTEM_Q_LEVEL_HIGH) {
qb_ipcs_request_rate_limit(ipcs_mapper[i].inst, QB_IPCS_RATE_SLOW);
}
}
}
static void cs_ipcs_fc_quorum_changed(int quorate, void *context)
{
ipc_fc_is_quorate = quorate;
cs_ipcs_check_for_flow_control();
}
static void cs_ipcs_totem_queue_level_changed(enum totem_q_level level)
{
ipc_fc_totem_queue_level = level;
cs_ipcs_check_for_flow_control();
}
void cs_ipcs_sync_state_changed(int32_t sync_in_process)
{
ipc_fc_sync_in_process = sync_in_process;
cs_ipcs_check_for_flow_control();
}
static void cs_ipcs_libqb_log_fn(const char *file_name,
int32_t file_line,
int32_t severity,
const char *msg)
{
int32_t level = severity;
if (severity > LOG_DEBUG) {
level = LOGSYS_LEVEL_DEBUG;
}
_logsys_log_printf (LOGSYS_ENCODE_RECID(level,
ipc_subsys_id,
LOGSYS_RECID_LOG),
__func__, file_name, file_line, "%s", msg);
}
void cs_ipcs_stats_update(void)
{
int32_t i;
struct qb_ipcs_stats srv_stats;
struct qb_ipcs_connection_stats stats;
qb_ipcs_connection_t *c;
struct cs_ipcs_conn_context *cnx;
for (i = 0; i < SERVICE_HANDLER_MAXIMUM_COUNT; i++) {
if (ais_service[i] == NULL) {
continue;
}
qb_ipcs_stats_get(ipcs_mapper[i].inst, &srv_stats, QB_FALSE);
for (c = qb_ipcs_connection_first_get(ipcs_mapper[i].inst); c;
c = qb_ipcs_connection_next_get(ipcs_mapper[i].inst, c)) {
cnx = qb_ipcs_context_get(c);
if (cnx == NULL) continue;
qb_ipcs_connection_stats_get(c, &stats, QB_FALSE);
api->object_key_replace(cnx->stats_handle,
"client_pid", strlen("client_pid"),
&stats.client_pid, sizeof(uint32_t));
api->object_key_replace(cnx->stats_handle,
"requests", strlen("requests"),
&stats.requests, sizeof(uint64_t));
api->object_key_replace(cnx->stats_handle,
"responses", strlen("responses"),
&stats.responses, sizeof(uint64_t));
api->object_key_replace(cnx->stats_handle,
"dispatched", strlen("dispatched"),
&stats.events, sizeof(uint64_t));
api->object_key_replace(cnx->stats_handle,
"send_retries", strlen("send_retries"),
&stats.send_retries, sizeof(uint64_t));
api->object_key_replace(cnx->stats_handle,
"recv_retries", strlen("recv_retries"),
&stats.recv_retries, sizeof(uint64_t));
api->object_key_replace(cnx->stats_handle,
"flow_control_count", strlen("flow_control_count"),
&stats.flow_control_count, sizeof(uint64_t));
api->object_key_replace(cnx->stats_handle,
"flow_control_state", strlen("flow_control_state"),
&stats.flow_control_state, sizeof(uint32_t));
qb_ipcs_connection_unref(c);
}
}
}
void cs_ipcs_service_init(struct corosync_service_engine *service)
{
ipcs_mapper[service->id].id = service->id;
strcpy(ipcs_mapper[service->id].name, cs_ipcs_serv_short_name(service->id));
log_printf (LOGSYS_LEVEL_INFO,
"Initializing IPC on %s [%d]",
ipcs_mapper[service->id].name,
ipcs_mapper[service->id].id);
ipcs_mapper[service->id].inst = qb_ipcs_create(ipcs_mapper[service->id].name,
ipcs_mapper[service->id].id,
QB_IPC_SHM,
&corosync_service_funcs);
assert(ipcs_mapper[service->id].inst);
qb_ipcs_poll_handlers_set(ipcs_mapper[service->id].inst,
&corosync_poll_funcs);
qb_ipcs_run(ipcs_mapper[service->id].inst);
}
void cs_ipcs_init(void)
{
qb_handle_t object_find_handle;
qb_handle_t object_runtime_handle;
uint64_t zero_64 = 0;
api = apidef_get ();
qb_loop_poll_low_fds_event_set(corosync_poll_handle_get(), cs_ipcs_low_fds_event);
ipc_subsys_id = _logsys_subsys_create ("IPC");
if (ipc_subsys_id < 0) {
log_printf (LOGSYS_LEVEL_ERROR,
"Could not initialize IPC logging subsystem\n");
corosync_exit_error (AIS_DONE_INIT_SERVICES);
}
qb_util_set_log_function (cs_ipcs_libqb_log_fn);
api->quorum_register_callback (cs_ipcs_fc_quorum_changed, NULL);
totempg_queue_level_register_callback (cs_ipcs_totem_queue_level_changed);
api->object_find_create (OBJECT_PARENT_HANDLE,
"runtime", strlen ("runtime"),
&object_find_handle);
if (api->object_find_next (object_find_handle,
&object_runtime_handle) != 0) {
log_printf (LOGSYS_LEVEL_ERROR,"arrg no runtime");
return;
}
/* Connection objects */
api->object_create (object_runtime_handle,
&object_connection_handle,
"connections", strlen ("connections"));
api->object_key_create_typed (object_connection_handle,
"active", &zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
api->object_key_create_typed (object_connection_handle,
"closed", &zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
}

View File

@ -97,10 +97,11 @@
#include <qb/qbdefs.h>
#include <qb/qbloop.h>
#include <qb/qbutil.h>
#include <qb/qbipcs.h>
#include <corosync/swab.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <corosync/corodefs.h>
#include <corosync/list.h>
#include <corosync/lcr/lcr_ifact.h>
@ -108,7 +109,6 @@
#include <corosync/engine/objdb.h>
#include <corosync/engine/config.h>
#include <corosync/engine/logsys.h>
#include <corosync/coroipcs.h>
#include "quorum.h"
#include "totemsrp.h"
@ -117,7 +117,6 @@
#include "main.h"
#include "sync.h"
#include "syncv2.h"
#include "tlist.h"
#include "timer.h"
#include "util.h"
#include "apidef.h"
@ -150,7 +149,7 @@ static int sched_priority = 0;
static unsigned int service_count = 32;
static pthread_mutex_t serialize_mutex = PTHREAD_MUTEX_INITIALIZER;
static qb_thread_lock_t *serialize_lock_f;
static struct totem_logging_configuration totem_logging_configuration;
@ -170,8 +169,6 @@ static qb_loop_t *corosync_poll_handle;
struct sched_param global_sched_param;
static hdb_handle_t object_connection_handle;
static hdb_handle_t object_memb_handle;
static corosync_timer_handle_t corosync_stats_timer_handle;
@ -182,8 +179,6 @@ static sem_t corosync_exit_sem;
static const char *corosync_lock_file = LOCALSTATEDIR"/run/corosync.pid";
static int32_t corosync_not_enough_fds_left = 0;
static void serialize_unlock (void);
static void serialize_lock (void);
@ -313,16 +308,14 @@ static struct totempg_group corosync_group = {
.group_len = 1
};
static void serialize_lock (void)
{
pthread_mutex_lock (&serialize_mutex);
qb_thread_lock (serialize_lock_f);
}
static void serialize_unlock (void)
{
pthread_mutex_unlock (&serialize_mutex);
qb_thread_unlock (serialize_lock_f);
}
static void corosync_sync_completed (void)
@ -330,6 +323,8 @@ static void corosync_sync_completed (void)
log_printf (LOGSYS_LEVEL_NOTICE,
"Completed service synchronization, ready to provide service.\n");
sync_in_process = 0;
cs_ipcs_sync_state_changed(sync_in_process);
}
static int corosync_sync_callbacks_retrieve (int sync_id,
@ -491,6 +486,7 @@ static void confchg_fn (
abort_activate = 1;
}
sync_in_process = 1;
cs_ipcs_sync_state_changed(sync_in_process);
serialize_lock ();
memcpy (&corosync_ring_id, ring_id, sizeof (struct memb_ring_id));
@ -737,6 +733,9 @@ static void corosync_totem_stats_updater (void *data)
"avg_backlog_calc", strlen("avg_backlog_calc"),
&avg_backlog_calc, sizeof (avg_backlog_calc));
}
cs_ipcs_stats_update();
api->timer_add_duration (1500 * MILLI_2_NANO_SECONDS, NULL,
corosync_totem_stats_updater,
&corosync_stats_timer_handle);
@ -887,17 +886,20 @@ static void deliver_fn (
unsigned int msg_len,
int endian_conversion_required)
{
const coroipc_request_header_t *header;
int service;
int fn_id;
unsigned int id;
unsigned int key_incr_dummy;
const struct qb_ipc_request_header *header;
int32_t service;
int32_t fn_id;
uint32_t id;
uint32_t size;
uint32_t key_incr_dummy;
header = msg;
if (endian_conversion_required) {
id = swab32 (header->id);
size = swab32 (header->size);
} else {
id = header->id;
size = header->size;
}
/*
@ -951,10 +953,10 @@ int main_mcast (
unsigned int iov_len,
unsigned int guarantee)
{
const coroipc_request_header_t *req = iovec->iov_base;
int service;
int fn_id;
unsigned int key_incr_dummy;
const struct qb_ipc_request_header *req = iovec->iov_base;
int32_t service;
int32_t fn_id;
uint32_t key_incr_dummy;
service = req->id >> 16;
fn_id = req->id & 0xffff;
@ -967,6 +969,85 @@ int main_mcast (
return (totempg_groups_mcast_joined (corosync_group_handle, iovec, iov_len, guarantee));
}
void corosync_recheck_the_q_level(void *data)
{
qb_loop_timer_handle tm;
totempg_check_q_level(corosync_group_handle);
if (cs_ipcs_q_level_get() == TOTEM_Q_LEVEL_CRITICAL) {
qb_loop_timer_add(corosync_poll_handle_get(), QB_LOOP_MED, 1,
NULL, corosync_recheck_the_q_level, &tm);
}
}
struct sending_allowed_private_data_struct {
int reserved_msgs;
};
int corosync_sending_allowed (
unsigned int service,
unsigned int id,
const void *msg,
void *sending_allowed_private_data)
{
struct sending_allowed_private_data_struct *pd =
(struct sending_allowed_private_data_struct *)sending_allowed_private_data;
struct iovec reserve_iovec;
struct qb_ipc_request_header *header = (struct qb_ipc_request_header *)msg;
int sending_allowed;
reserve_iovec.iov_base = (char *)header;
reserve_iovec.iov_len = header->size;
pd->reserved_msgs = totempg_groups_joined_reserve (
corosync_group_handle,
&reserve_iovec, 1);
if (pd->reserved_msgs == -1) {
return (-1);
}
sending_allowed = QB_FALSE;
if (corosync_quorum_is_quorate() == 1 ||
ais_service[service]->allow_inquorate == CS_LIB_ALLOW_INQUORATE) {
// we are quorate
// now check flow control
if (ais_service[service]->lib_engine[id].flow_control == CS_LIB_FLOW_CONTROL_NOT_REQUIRED) {
sending_allowed = QB_TRUE;
} else if (pd->reserved_msgs && sync_in_process == 0) {
sending_allowed = QB_TRUE;
} else {
log_printf(LOGSYS_LEVEL_NOTICE,
"no tx: (have quorum) (FC req) reserved:%d sync:%d",
pd->reserved_msgs, sync_in_process);
}
} else {
log_printf(LOGSYS_LEVEL_NOTICE, "no tx: not quorate!");
}
/*
sending_allowed =
(corosync_quorum_is_quorate() == 1 ||
ais_service[service]->allow_inquorate == CS_LIB_ALLOW_INQUORATE) &&
((ais_service[service]->lib_engine[id].flow_control == CS_LIB_FLOW_CONTROL_NOT_REQUIRED) ||
((ais_service[service]->lib_engine[id].flow_control == CS_LIB_FLOW_CONTROL_REQUIRED) &&
(pd->reserved_msgs) &&
(sync_in_process == 0)));
*/
return (sending_allowed);
}
void corosync_sending_allowed_release (void *sending_allowed_private_data)
{
struct sending_allowed_private_data_struct *pd =
(struct sending_allowed_private_data_struct *)sending_allowed_private_data;
if (pd->reserved_msgs == -1) {
return;
}
totempg_groups_joined_release (pd->reserved_msgs);
}
int message_source_is_local (const mar_message_source_t *source)
{
int ret = 0;
@ -988,330 +1069,6 @@ void message_source_set (
source->conn = conn;
}
/*
* Provides the glue from corosync to the IPC Service
*/
static int corosync_private_data_size_get (unsigned int service)
{
return (ais_service[service]->private_data_size);
}
static coroipcs_init_fn_lvalue corosync_init_fn_get (unsigned int service)
{
return (ais_service[service]->lib_init_fn);
}
static coroipcs_exit_fn_lvalue corosync_exit_fn_get (unsigned int service)
{
return (ais_service[service]->lib_exit_fn);
}
static coroipcs_handler_fn_lvalue corosync_handler_fn_get (unsigned int service, unsigned int id)
{
return (ais_service[service]->lib_engine[id].lib_handler_fn);
}
static int corosync_security_valid (int euid, int egid)
{
struct list_head *iter;
if (corosync_not_enough_fds_left) {
errno = EMFILE;
return (0);
}
if (euid == 0 || egid == 0) {
return (1);
}
for (iter = uidgid_list_head.next; iter != &uidgid_list_head;
iter = iter->next) {
struct uidgid_item *ugi = list_entry (iter, struct uidgid_item,
list);
if (euid == ugi->uid || egid == ugi->gid)
return (1);
}
errno = EACCES;
return (0);
}
static int corosync_service_available (unsigned int service)
{
return (ais_service[service] != NULL && !ais_service_exiting[service]);
}
struct sending_allowed_private_data_struct {
int reserved_msgs;
};
static int corosync_sending_allowed (
unsigned int service,
unsigned int id,
const void *msg,
void *sending_allowed_private_data)
{
struct sending_allowed_private_data_struct *pd =
(struct sending_allowed_private_data_struct *)sending_allowed_private_data;
struct iovec reserve_iovec;
coroipc_request_header_t *header = (coroipc_request_header_t *)msg;
int sending_allowed;
reserve_iovec.iov_base = (char *)header;
reserve_iovec.iov_len = header->size;
pd->reserved_msgs = totempg_groups_joined_reserve (
corosync_group_handle,
&reserve_iovec, 1);
if (pd->reserved_msgs == -1) {
return (-1);
}
sending_allowed =
(corosync_quorum_is_quorate() == 1 ||
ais_service[service]->allow_inquorate == CS_LIB_ALLOW_INQUORATE) &&
((ais_service[service]->lib_engine[id].flow_control == CS_LIB_FLOW_CONTROL_NOT_REQUIRED) ||
((ais_service[service]->lib_engine[id].flow_control == CS_LIB_FLOW_CONTROL_REQUIRED) &&
(pd->reserved_msgs) &&
(sync_in_process == 0)));
return (sending_allowed);
}
static void corosync_sending_allowed_release (void *sending_allowed_private_data)
{
struct sending_allowed_private_data_struct *pd =
(struct sending_allowed_private_data_struct *)sending_allowed_private_data;
if (pd->reserved_msgs == -1) {
return;
}
totempg_groups_joined_release (pd->reserved_msgs);
}
static int ipc_subsys_id = -1;
static void ipc_fatal_error(const char *error_msg) __attribute__((noreturn));
static void ipc_fatal_error(const char *error_msg) {
_logsys_log_printf (
LOGSYS_ENCODE_RECID(LOGSYS_LEVEL_ERROR,
ipc_subsys_id,
LOGSYS_RECID_LOG),
__FUNCTION__, __FILE__, __LINE__,
"%s", error_msg);
exit(EXIT_FAILURE);
}
static int corosync_poll_handler_accept (
int fd,
int revent,
void *context)
{
return (coroipcs_handler_accept (fd, revent, context));
}
static int corosync_poll_handler_dispatch (
int fd,
int revent,
void *context)
{
return (coroipcs_handler_dispatch (fd, revent, context));
}
static void corosync_poll_accept_add (
int fd)
{
qb_loop_poll_add (corosync_poll_handle, QB_LOOP_MED, fd, POLLIN|POLLNVAL, 0,
corosync_poll_handler_accept);
}
static void corosync_poll_dispatch_add (
int fd,
void *context)
{
qb_loop_poll_add (corosync_poll_handle, QB_LOOP_MED, fd, POLLIN|POLLNVAL, context,
corosync_poll_handler_dispatch);
}
static void corosync_poll_dispatch_modify (
int fd,
int events,
void *context)
{
qb_loop_poll_mod (corosync_poll_handle, QB_LOOP_MED, fd, events, context,
corosync_poll_handler_dispatch);
}
static void corosync_poll_dispatch_destroy (
int fd,
void *context)
{
qb_loop_poll_del (corosync_poll_handle, fd);
}
static hdb_handle_t corosync_stats_create_connection (const char* name,
const pid_t pid, const int fd)
{
uint32_t zero_32 = 0;
uint64_t zero_64 = 0;
unsigned int key_incr_dummy;
hdb_handle_t object_handle;
objdb->object_key_increment (object_connection_handle,
"active", strlen("active"),
&key_incr_dummy);
objdb->object_create (object_connection_handle,
&object_handle,
name,
strlen (name));
objdb->object_key_create_typed (object_handle,
"service_id",
&zero_32, sizeof (zero_32),
OBJDB_VALUETYPE_UINT32);
objdb->object_key_create_typed (object_handle,
"client_pid",
&pid, sizeof (pid),
OBJDB_VALUETYPE_INT32);
objdb->object_key_create_typed (object_handle,
"responses",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
objdb->object_key_create_typed (object_handle,
"dispatched",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
objdb->object_key_create_typed (object_handle,
"requests",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_INT64);
objdb->object_key_create_typed (object_handle,
"sem_retry_count",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
objdb->object_key_create_typed (object_handle,
"send_retry_count",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
objdb->object_key_create_typed (object_handle,
"recv_retry_count",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
objdb->object_key_create_typed (object_handle,
"flow_control",
&zero_32, sizeof (zero_32),
OBJDB_VALUETYPE_UINT32);
objdb->object_key_create_typed (object_handle,
"flow_control_count",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
objdb->object_key_create_typed (object_handle,
"queue_size",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
objdb->object_key_create_typed (object_handle,
"invalid_request",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
objdb->object_key_create_typed (object_handle,
"overload",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
return object_handle;
}
static void corosync_stats_destroy_connection (hdb_handle_t handle)
{
unsigned int key_incr_dummy;
objdb->object_destroy (handle);
objdb->object_key_increment (object_connection_handle,
"closed", strlen("closed"),
&key_incr_dummy);
objdb->object_key_decrement (object_connection_handle,
"active", strlen("active"),
&key_incr_dummy);
}
static void corosync_stats_update_value (hdb_handle_t handle,
const char *name, const void *value,
size_t value_len)
{
objdb->object_key_replace (handle,
name, strlen(name),
value, value_len);
}
static void corosync_stats_increment_value (hdb_handle_t handle,
const char* name)
{
unsigned int key_incr_dummy;
objdb->object_key_increment (handle,
name, strlen(name),
&key_incr_dummy);
}
static void corosync_stats_decrement_value (hdb_handle_t handle,
const char* name)
{
unsigned int key_incr_dummy;
objdb->object_key_decrement (handle,
name, strlen(name),
&key_incr_dummy);
}
static struct coroipcs_init_state_v2 ipc_init_state_v2 = {
.socket_name = COROSYNC_SOCKET_NAME,
.sched_policy = SCHED_OTHER,
.sched_param = &global_sched_param,
.malloc = malloc,
.free = free,
.log_printf = _logsys_log_printf,
.fatal_error = ipc_fatal_error,
.security_valid = corosync_security_valid,
.service_available = corosync_service_available,
.private_data_size_get = corosync_private_data_size_get,
.serialize_lock = serialize_lock,
.serialize_unlock = serialize_unlock,
.sending_allowed = corosync_sending_allowed,
.sending_allowed_release = corosync_sending_allowed_release,
.poll_accept_add = corosync_poll_accept_add,
.poll_dispatch_add = corosync_poll_dispatch_add,
.poll_dispatch_modify = corosync_poll_dispatch_modify,
.poll_dispatch_destroy = corosync_poll_dispatch_destroy,
.init_fn_get = corosync_init_fn_get,
.exit_fn_get = corosync_exit_fn_get,
.handler_fn_get = corosync_handler_fn_get,
.stats_create_connection = corosync_stats_create_connection,
.stats_destroy_connection = corosync_stats_destroy_connection,
.stats_update_value = corosync_stats_update_value,
.stats_increment_value = corosync_stats_increment_value,
.stats_decrement_value = corosync_stats_decrement_value,
};
static void corosync_setscheduler (void)
{
#if defined(HAVE_PTHREAD_SETSCHEDPARAM) && defined(HAVE_SCHED_GET_PRIORITY_MAX) && defined(HAVE_SCHED_SETSCHEDULER)
@ -1329,10 +1086,6 @@ static void corosync_setscheduler (void)
global_sched_param.sched_priority = 0;
logsys_thread_priority_set (SCHED_OTHER, NULL, 1);
} else {
/*
* Turn on SCHED_RR in ipc system
*/
ipc_init_state_v2.sched_policy = SCHED_RR;
/*
* Turn on SCHED_RR in logsys system
@ -1407,49 +1160,10 @@ static void corosync_fplay_control_init (void)
NULL, NULL, NULL, NULL);
}
static void corosync_stats_init (void)
{
hdb_handle_t object_find_handle;
hdb_handle_t object_runtime_handle;
uint64_t zero_64 = 0;
objdb->object_find_create (OBJECT_PARENT_HANDLE,
"runtime", strlen ("runtime"),
&object_find_handle);
if (objdb->object_find_next (object_find_handle,
&object_runtime_handle) != 0) {
return;
}
/* Connection objects */
objdb->object_create (object_runtime_handle,
&object_connection_handle,
"connections", strlen ("connections"));
objdb->object_key_create_typed (object_connection_handle,
"active", &zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
objdb->object_key_create_typed (object_connection_handle,
"closed", &zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
}
static void main_low_fds_event(int32_t not_enough, int32_t fds_available)
{
corosync_not_enough_fds_left = not_enough;
if (not_enough) {
log_printf(LOGSYS_LEVEL_WARNING, "refusing new connections (fds_available:%d)\n",
fds_available);
} else {
log_printf(LOGSYS_LEVEL_NOTICE, "allowing new connections (fds_available:%d)\n",
fds_available);
}
}
static void main_service_ready (void)
{
int res;
/*
* This must occur after totempg is initialized because "this_ip" must be set
*/
@ -1459,7 +1173,7 @@ static void main_service_ready (void)
corosync_exit_error (AIS_DONE_INIT_SERVICES);
}
evil_init (api);
corosync_stats_init ();
cs_ipcs_init();
corosync_totem_stats_init ();
corosync_fplay_control_init ();
if (minimum_sync_mode == CS_SYNC_V2) {
@ -1592,7 +1306,9 @@ int main (int argc, char **argv, char **envp)
hdb_handle_t object_runtime_handle;
enum e_ais_done flock_err;
/* default configuration
serialize_lock_f = qb_thread_lock_create (QB_THREAD_LOCK_SHORT);
/* default configuration
*/
background = 1;
setprio = 1;
@ -1820,7 +1536,6 @@ int main (int argc, char **argv, char **envp)
sched_priority);
corosync_poll_handle = qb_loop_create ();
qb_loop_poll_low_fds_event_set(corosync_poll_handle, main_low_fds_event);
/*
* Sleep for a while to let other nodes in the cluster
@ -1886,16 +1601,6 @@ int main (int argc, char **argv, char **envp)
serialize_lock,
serialize_unlock);
ipc_subsys_id = _logsys_subsys_create ("IPC");
if (ipc_subsys_id < 0) {
log_printf (LOGSYS_LEVEL_ERROR,
"Could not initialize IPC logging subsystem\n");
corosync_exit_error (AIS_DONE_INIT_SERVICES);
}
ipc_init_state_v2.log_subsys_id = ipc_subsys_id;
coroipcs_ipc_init_v2 (&ipc_init_state_v2);
/*
* Start main processing loop
*/

View File

@ -85,4 +85,42 @@ extern int cs_poll_dispatch_delete (
int fd);
extern int corosync_sending_allowed (
unsigned int service,
unsigned int id,
const void *msg,
void *sending_allowed_private_data);
extern void corosync_sending_allowed_release (void *sending_allowed_private_data);
extern void corosync_recheck_the_q_level(void *data);
extern void cs_ipcs_init(void);
extern void cs_ipcs_service_init(struct corosync_service_engine *service);
extern void cs_ipcs_stats_update(void);
extern int32_t cs_ipcs_service_destroy(int32_t service_id);
extern int32_t cs_ipcs_q_level_get(void);
extern int cs_ipcs_dispatch_send(void *conn, const void *msg, size_t mlen);
extern int cs_ipcs_dispatch_iov_send (void *conn,
const struct iovec *iov,
unsigned int iov_len);
extern int cs_ipcs_response_send(void *conn, const void *msg, size_t mlen);
extern int cs_ipcs_response_iov_send (void *conn,
const struct iovec *iov,
unsigned int iov_len);
extern void cs_ipcs_sync_state_changed(int32_t sync_in_process);
extern void *cs_ipcs_private_data_get(void *conn);
extern void cs_ipc_refcnt_inc(void *conn);
extern void cs_ipc_refcnt_dec(void *conn);
#endif /* MAIN_H_DEFINED */

View File

@ -39,6 +39,7 @@
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <pthread.h>
@ -48,7 +49,7 @@
#include <corosync/engine/objdb.h>
#include <corosync/engine/config.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <qb/qbipc_common.h>
#include "main.h"

View File

@ -51,7 +51,6 @@
#include <arpa/inet.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <corosync/swab.h>
#include <corosync/totem/totempg.h>
#include <corosync/totem/totem.h>

View File

@ -43,7 +43,6 @@
#include <corosync/totem/totem.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include "mainconfig.h"
#include "util.h"
#include <corosync/engine/logsys.h>
@ -55,7 +54,7 @@
#include <corosync/engine/coroapi.h>
#include "service.h"
#include <corosync/coroipcs.h>
#include <qb/qbipcs.h>
LOGSYS_DECLARE_SUBSYS ("SERV");
@ -248,33 +247,35 @@ unsigned int corosync_service_link_and_init (
name_sufix = (char*)service_name;
corosync_api->object_create (object_stats_services_handle,
&object_stats_handle,
name_sufix, strlen (name_sufix));
&object_stats_handle,
name_sufix, strlen (name_sufix));
corosync_api->object_key_create_typed (object_stats_handle,
"service_id",
&service->id, sizeof (service->id),
OBJDB_VALUETYPE_INT16);
"service_id",
&service->id, sizeof (service->id),
OBJDB_VALUETYPE_INT16);
for (fn = 0; fn < service->exec_engine_count; fn++) {
snprintf (object_name, 32, "%d", fn);
corosync_api->object_create (object_stats_handle,
&service_stats_handle[service->id][fn],
object_name, strlen (object_name));
&service_stats_handle[service->id][fn],
object_name, strlen (object_name));
corosync_api->object_key_create_typed (service_stats_handle[service->id][fn],
"tx",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
"tx",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
corosync_api->object_key_create_typed (service_stats_handle[service->id][fn],
"rx",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
"rx",
&zero_64, sizeof (zero_64),
OBJDB_VALUETYPE_UINT64);
}
log_printf (LOGSYS_LEVEL_NOTICE, "Service engine loaded: %s\n", service->name);
log_printf (LOGSYS_LEVEL_NOTICE,
"Service engine loaded: %s [%d]\n", service->name, service->id);
cs_ipcs_service_init(service);
return (res);
}
@ -580,7 +581,7 @@ static int service_unlink_schedwrk_handler (const void *data) {
/*
* Exit all ipc connections dependent on this service
*/
if (coroipcs_ipc_service_exit (cb_data->service_engine) == -1)
if (cs_ipcs_service_destroy (cb_data->service_engine) == -1)
return -1;
log_printf(LOGSYS_LEVEL_NOTICE,

View File

@ -56,7 +56,7 @@
#include <corosync/totem/totem.h>
#include <corosync/lcr/lcr_ifact.h>
#include <corosync/engine/logsys.h>
#include <corosync/coroipc_types.h>
#include <qb/qbipc_common.h>
#include "quorum.h"
#include "sync.h"
@ -145,7 +145,7 @@ static struct totempg_group sync_group = {
static hdb_handle_t sync_group_handle;
struct req_exec_sync_barrier_start {
coroipc_request_header_t header;
struct qb_ipc_request_header header;
struct memb_ring_id ring_id;
};

View File

@ -55,7 +55,7 @@
#include <corosync/totem/totem.h>
#include <corosync/lcr/lcr_ifact.h>
#include <corosync/engine/logsys.h>
#include <corosync/coroipc_types.h>
#include <qb/qbipc_common.h>
#include "schedwrk.h"
#include "quorum.h"
#include "sync.h"
@ -96,19 +96,19 @@ struct processor_entry {
};
struct req_exec_memb_determine_message {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
struct memb_ring_id ring_id __attribute__((aligned(8)));
};
struct req_exec_service_build_message {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
struct memb_ring_id ring_id __attribute__((aligned(8)));
int service_list_entries __attribute__((aligned(8)));
int service_list[128] __attribute__((aligned(8)));
};
struct req_exec_barrier_message {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
struct memb_ring_id ring_id __attribute__((aligned(8)));
};
@ -383,7 +383,7 @@ static void sync_deliver_fn (
unsigned int msg_len,
int endian_conversion_required)
{
coroipc_request_header_t *header = (coroipc_request_header_t *)msg;
struct qb_ipc_request_header *header = (struct qb_ipc_request_header *)msg;
switch (header->id) {
case MESSAGE_REQ_SYNC_BARRIER:

View File

@ -59,7 +59,6 @@
#include <corosync/swab.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <corosync/list.h>
#include <corosync/lcr/lcr_ifact.h>
#include <qb/qbloop.h>

View File

@ -164,6 +164,8 @@ static int totempg_reserved = 1;
static unsigned int totempg_size_limit;
static totem_queue_level_changed_fn totem_queue_level_changed = NULL;
/*
* Function and data used to log messages
*/
@ -244,6 +246,7 @@ struct totempg_group_instance {
struct totempg_group *groups;
int groups_cnt;
int32_t q_level;
};
DECLARE_HDB_DATABASE (totempg_groups_instance_database,NULL);
@ -1061,6 +1064,7 @@ int totempg_groups_initialize (
instance->confchg_fn = confchg_fn;
instance->groups = 0;
instance->groups_cnt = 0;
instance->q_level = QB_LOOP_MED;
hdb_handle_put (&totempg_groups_instance_database, *handle);
@ -1178,6 +1182,42 @@ error_exit:
return (res);
}
static void check_q_level(struct totempg_group_instance *instance)
{
int32_t old_level;
int32_t percent_used = 0;
old_level = instance->q_level;
percent_used = 100 - (totemmrp_avail () * 100 / 800); /*(1024*1024/1500)*/
if (percent_used > 90 && instance->q_level != TOTEM_Q_LEVEL_CRITICAL) {
instance->q_level = TOTEM_Q_LEVEL_CRITICAL;
} else if (percent_used < 30 && instance->q_level != TOTEM_Q_LEVEL_LOW) {
instance->q_level = TOTEM_Q_LEVEL_LOW;
} else if (percent_used > 40 && percent_used < 60 && instance->q_level != TOTEM_Q_LEVEL_GOOD) {
instance->q_level = TOTEM_Q_LEVEL_GOOD;
} else if (percent_used > 70 && percent_used < 80 && instance->q_level != TOTEM_Q_LEVEL_HIGH) {
instance->q_level = TOTEM_Q_LEVEL_HIGH;
}
if (totem_queue_level_changed && old_level != instance->q_level) {
totem_queue_level_changed(instance->q_level);
}
}
void totempg_check_q_level(qb_handle_t handle)
{
struct totempg_group_instance *instance;
if (hdb_handle_get (&totempg_groups_instance_database, handle,
(void *)&instance) != 0) {
return;
}
check_q_level(instance);
hdb_handle_put (&totempg_groups_instance_database, handle);
}
int totempg_groups_joined_reserve (
hdb_handle_t handle,
const struct iovec *iovec,
@ -1203,6 +1243,8 @@ int totempg_groups_joined_reserve (
for (i = 0; i < iov_len; i++) {
size += iovec[i].iov_len;
}
check_q_level(instance);
if (size >= totempg_size_limit) {
reserved = -1;
goto error_put;
@ -1404,6 +1446,11 @@ extern void totempg_service_ready_register (
totemmrp_service_ready_register (totem_service_ready);
}
void totempg_queue_level_register_callback (totem_queue_level_changed_fn fn)
{
totem_queue_level_changed = fn;
}
extern int totempg_member_add (
const struct totem_ip_address *member,
int ring_no);

View File

@ -59,9 +59,9 @@
#include <limits.h>
#include <corosync/sq.h>
#include <corosync/swab.h>
#include <corosync/list.h>
#include <corosync/hdb.h>
#include <corosync/swab.h>
#include <qb/qbloop.h>
#define LOGSYS_UTILS_ONLY 1
#include <corosync/engine/logsys.h>

View File

@ -978,19 +978,6 @@ void setutxent(void)
}
#endif
char *strerror(int errnum)
{
static char *(*real_strerror)(int errnum) = NULL;
if (!tsafe_inited || tsafe_disabled) {
if (real_strerror == NULL) {
real_strerror = _get_real_func_ ("strerror");
}
return real_strerror (errnum);
}
assert(0);
return NULL;
}
char *strsignal(int sig)
{
static char *(*real_strsignal)(int sig) = NULL;

View File

@ -47,7 +47,6 @@
#include <corosync/corodefs.h>
#include <corosync/list.h>
#include <corosync/engine/logsys.h>
#include <corosync/coroipc_types.h>
#include "util.h"
LOGSYS_DECLARE_SUBSYS ("MAIN");

View File

@ -71,17 +71,17 @@ static inline cs_error_t hdb_error_to_cs (int res) \
if (res == 0) { \
return (CS_OK); \
} else { \
if (errno == EBADF) { \
if (res == -EBADF) { \
return (CS_ERR_BAD_HANDLE); \
} else \
if (errno == ENOMEM) { \
if (res == -ENOMEM) { \
return (CS_ERR_NO_MEMORY); \
} else \
if (errno == EMFILE) { \
if (res == -EMFILE) { \
return (CS_ERR_NO_RESOURCES); \
} else \
if (errno == EACCES) { \
return (CS_ERR_SECURITY); \
if (res == -EACCES) { \
return (CS_ERR_ACCESS); \
} \
return (CS_ERR_LIBRARY); \
} \

View File

@ -55,7 +55,7 @@
#include <time.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <qb/qbipc_common.h>
#include <corosync/corodefs.h>
#include <corosync/swab.h>
#include <corosync/list.h>
@ -440,7 +440,7 @@ static void message_handler_req_lib_quorum_trackstart (void *conn,
const void *msg)
{
const struct req_lib_quorum_trackstart *req_lib_quorum_trackstart = msg;
coroipc_response_header_t res;
struct qb_ipc_response_header res;
struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
log_printf(LOGSYS_LEVEL_DEBUG, "got trackstart request on %p\n", conn);
@ -471,12 +471,12 @@ static void message_handler_req_lib_quorum_trackstart (void *conn,
res.size = sizeof(res);
res.id = MESSAGE_RES_QUORUM_TRACKSTART;
res.error = CS_OK;
corosync_api->ipc_response_send(conn, &res, sizeof(coroipc_response_header_t));
corosync_api->ipc_response_send(conn, &res, sizeof(struct qb_ipc_response_header));
}
static void message_handler_req_lib_quorum_trackstop (void *conn, const void *msg)
{
coroipc_response_header_t res;
struct qb_ipc_response_header res;
struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
log_printf(LOGSYS_LEVEL_DEBUG, "got trackstop request on %p\n", conn);
@ -494,5 +494,5 @@ static void message_handler_req_lib_quorum_trackstop (void *conn, const void *ms
res.size = sizeof(res);
res.id = MESSAGE_RES_QUORUM_TRACKSTOP;
res.error = CS_OK;
corosync_api->ipc_response_send(conn, &res, sizeof(coroipc_response_header_t));
corosync_api->ipc_response_send(conn, &res, sizeof(struct qb_ipc_response_header));
}

View File

@ -58,7 +58,7 @@
#include <corosync/engine/logsys.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <qb/qbipc_common.h>
#include <corosync/mar_gen.h>
#include <corosync/engine/coroapi.h>
#include <corosync/engine/quorum.h>

View File

@ -32,11 +32,11 @@
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 \
coroipcc.h coroipcs.h coroipc_types.h corodefs.h \
corodefs.h \
confdb.h list.h corotypes.h quorum.h votequorum.h sam.h
CS_INTERNAL_H = ipc_cfg.h ipc_confdb.h ipc_cpg.h ipc_evs.h ipc_pload.h ipc_quorum.h \
jhash.h pload.h cs_queue.h quorum.h sq.h ipc_votequorum.h coroipc_ipc.h
jhash.h pload.h cs_queue.h quorum.h sq.h ipc_votequorum.h
LCR_H = lcr_ckpt.h lcr_comp.h lcr_ifact.h

View File

@ -37,8 +37,6 @@
#include <netinet/in.h>
#define COROSYNC_SOCKET_NAME "corosync.ipc"
enum corosync_service_types {
EVS_SERVICE = 0,
CLM_SERVICE = 1,

View File

@ -1,384 +0,0 @@
/*
* Copyright (c) 2009 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Steven Dake (sdake@redhat.com)
*
* This software licensed under BSD license, the text of which follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the MontaVista Software, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef COROIPC_IPC_H_DEFINED
#define COROIPC_IPC_H_DEFINED
#include <unistd.h>
#include <poll.h>
#include <time.h>
#include "corotypes.h"
#include "config.h"
/*
* Darwin claims to support process shared synchronization
* but it really does not. The unistd.h header file is wrong.
*/
#if defined(COROSYNC_DARWIN) || defined(__UCLIBC__)
#undef _POSIX_THREAD_PROCESS_SHARED
#define _POSIX_THREAD_PROCESS_SHARED -1
#endif
#ifndef _POSIX_THREAD_PROCESS_SHARED
#define _POSIX_THREAD_PROCESS_SHARED -1
#endif
#if _POSIX_THREAD_PROCESS_SHARED > 0
#include <semaphore.h>
#else
#include <sys/sem.h>
#if defined(_SEM_SEMUN_UNDEFINED)
union semun {
int val;
struct semid_ds *buf;
unsigned short int *array;
struct seminfo *__buf;
};
#endif
#endif
/*
* Define sem_wait timeout (real timeout will be (n-1;n) )
*/
#define IPC_SEMWAIT_TIMEOUT 2
#define IPC_SEMWAIT_NOFILE 0
enum req_init_types {
MESSAGE_REQ_RESPONSE_INIT = 0,
MESSAGE_REQ_DISPATCH_INIT = 1
};
#define MESSAGE_REQ_CHANGE_EUID 1
enum ipc_semaphore_identifiers {
SEMAPHORE_REQUEST_OR_FLUSH_OR_EXIT = 0,
SEMAPHORE_REQUEST = 1,
SEMAPHORE_RESPONSE = 2,
SEMAPHORE_DISPATCH = 3
};
struct control_buffer {
unsigned int read;
unsigned int write;
int flow_control_enabled;
#if _POSIX_THREAD_PROCESS_SHARED > 0
sem_t sem_request_or_flush_or_exit;
sem_t sem_response;
sem_t sem_dispatch;
sem_t sem_request;
#else
int semid;
#endif
int ipc_closed;
};
enum res_init_types {
MESSAGE_RES_INIT
};
typedef struct {
int service __attribute__((aligned(8)));
unsigned long long semkey __attribute__((aligned(8)));
char control_file[PATH_MAX] __attribute__((aligned(8)));
char request_file[PATH_MAX] __attribute__((aligned(8)));
char response_file[PATH_MAX] __attribute__((aligned(8)));
char dispatch_file[PATH_MAX] __attribute__((aligned(8)));
size_t control_size __attribute__((aligned(8)));
size_t request_size __attribute__((aligned(8)));
size_t response_size __attribute__((aligned(8)));
size_t dispatch_size __attribute__((aligned(8)));
} mar_req_setup_t __attribute__((aligned(8)));
typedef struct {
int error __attribute__((aligned(8)));
} mar_res_setup_t __attribute__((aligned(8)));
typedef struct {
uid_t euid __attribute__((aligned(8)));
gid_t egid __attribute__((aligned(8)));
} mar_req_priv_change __attribute__((aligned(8)));
typedef struct {
coroipc_response_header_t header __attribute__((aligned(8)));
uint64_t conn_info __attribute__((aligned(8)));
} mar_res_lib_response_init_t __attribute__((aligned(8)));
typedef struct {
coroipc_response_header_t header __attribute__((aligned(8)));
} mar_res_lib_dispatch_init_t __attribute__((aligned(8)));
typedef struct {
uint32_t nodeid __attribute__((aligned(8)));
void *conn __attribute__((aligned(8)));
} mar_message_source_t __attribute__((aligned(8)));
typedef struct {
coroipc_request_header_t header __attribute__((aligned(8)));
size_t map_size __attribute__((aligned(8)));
char path_to_file[128] __attribute__((aligned(8)));
} mar_req_coroipcc_zc_alloc_t __attribute__((aligned(8)));
typedef struct {
coroipc_request_header_t header __attribute__((aligned(8)));
size_t map_size __attribute__((aligned(8)));
uint64_t server_address __attribute__((aligned(8)));
} mar_req_coroipcc_zc_free_t __attribute__((aligned(8)));
typedef struct {
coroipc_request_header_t header __attribute__((aligned(8)));
uint64_t server_address __attribute__((aligned(8)));
} mar_req_coroipcc_zc_execute_t __attribute__((aligned(8)));
struct coroipcs_zc_header {
int map_size;
uint64_t server_address;
};
#define SOCKET_SERVICE_INIT 0xFFFFFFFF
#define SOCKET_SERVICE_SECURITY_VIOLATION 0xFFFFFFFE
#define ZC_ALLOC_HEADER 0xFFFFFFFF
#define ZC_FREE_HEADER 0xFFFFFFFE
#define ZC_EXECUTE_HEADER 0xFFFFFFFD
static inline cs_error_t
ipc_sem_wait (
struct control_buffer *control_buffer,
enum ipc_semaphore_identifiers sem_id,
int fd)
{
#if _POSIX_THREAD_PROCESS_SHARED < 1
struct sembuf sop;
#else
struct timespec timeout;
struct pollfd pfd;
sem_t *sem = NULL;
#endif
int res;
#if _POSIX_THREAD_PROCESS_SHARED > 0
switch (sem_id) {
case SEMAPHORE_REQUEST_OR_FLUSH_OR_EXIT:
sem = &control_buffer->sem_request_or_flush_or_exit;
break;
case SEMAPHORE_RESPONSE:
sem = &control_buffer->sem_request;
break;
case SEMAPHORE_DISPATCH:
sem = &control_buffer->sem_response;
break;
case SEMAPHORE_REQUEST:
sem = &control_buffer->sem_dispatch;
break;
}
if (fd == IPC_SEMWAIT_NOFILE) {
retry_sem_wait:
res = sem_wait (sem);
if (res == -1 && errno == EINTR) {
goto retry_sem_wait;
} else
if (res == -1) {
return (CS_ERR_LIBRARY);
}
} else {
if (control_buffer->ipc_closed) {
return (CS_ERR_LIBRARY);
}
timeout.tv_sec = time(NULL) + IPC_SEMWAIT_TIMEOUT;
timeout.tv_nsec = 0;
retry_sem_timedwait:
res = sem_timedwait (sem, &timeout);
if (res == -1 && errno == ETIMEDOUT) {
pfd.fd = fd;
pfd.events = 0;
/*
* Determine if server has failed (ERR_LIBRARY) or
* is just performing slowly or in configuration change
* (retry sem op)
*/
retry_poll:
res = poll (&pfd, 1, 0);
if (res == -1 && errno == EINTR) {
goto retry_poll;
} else
if (res == -1) {
return (CS_ERR_LIBRARY);
}
if (res == 1) {
if (pfd.revents == POLLERR ||
pfd.revents == POLLHUP ||
pfd.revents == POLLNVAL) {
return (CS_ERR_LIBRARY);
}
}
goto retry_sem_timedwait;
} else
if (res == -1 && errno == EINTR) {
goto retry_sem_timedwait;
} else
if (res == -1) {
return (CS_ERR_LIBRARY);
}
if (res == 0 && control_buffer->ipc_closed) {
return (CS_ERR_LIBRARY);
}
}
#else
sop.sem_num = sem_id;
sop.sem_op = -1;
sop.sem_flg = 0;
retry_semop:
res = semop (control_buffer->semid, &sop, 1);
if (res == -1 && errno == EINTR) {
return (CS_ERR_TRY_AGAIN);
goto retry_semop;
} else
if (res == -1 && errno == EACCES) {
return (CS_ERR_TRY_AGAIN);
} else
if (res == -1) {
return (CS_ERR_LIBRARY);
}
#endif
return (CS_OK);
}
static inline cs_error_t
ipc_sem_post (
struct control_buffer *control_buffer,
enum ipc_semaphore_identifiers sem_id)
{
#if _POSIX_THREAD_PROCESS_SHARED < 1
struct sembuf sop;
#else
sem_t *sem = NULL;
#endif
int res;
#if _POSIX_THREAD_PROCESS_SHARED > 0
switch (sem_id) {
case SEMAPHORE_REQUEST_OR_FLUSH_OR_EXIT:
sem = &control_buffer->sem_request_or_flush_or_exit;
break;
case SEMAPHORE_RESPONSE:
sem = &control_buffer->sem_request;
break;
case SEMAPHORE_DISPATCH:
sem = &control_buffer->sem_response;
break;
case SEMAPHORE_REQUEST:
sem = &control_buffer->sem_dispatch;
break;
}
res = sem_post (sem);
if (res == -1) {
return (CS_ERR_LIBRARY);
}
#else
sop.sem_num = sem_id;
sop.sem_op = 1;
sop.sem_flg = 0;
retry_semop:
res = semop (control_buffer->semid, &sop, 1);
if (res == -1 && errno == EINTR) {
goto retry_semop;
} else
if (res == -1) {
return (CS_ERR_LIBRARY);
}
#endif
return (CS_OK);
}
static inline cs_error_t
ipc_sem_getvalue (
struct control_buffer *control_buffer,
enum ipc_semaphore_identifiers sem_id,
int *sem_value)
{
#if _POSIX_THREAD_PROCESS_SHARED < 1
int sem_value_hold;
union semun semun;
#else
sem_t *sem = NULL;
int res;
#endif
#if _POSIX_THREAD_PROCESS_SHARED > 0
switch (sem_id) {
case SEMAPHORE_REQUEST_OR_FLUSH_OR_EXIT:
sem = &control_buffer->sem_request_or_flush_or_exit;
break;
case SEMAPHORE_RESPONSE:
sem = &control_buffer->sem_request;
break;
case SEMAPHORE_DISPATCH:
sem = &control_buffer->sem_response;
break;
case SEMAPHORE_REQUEST:
sem = &control_buffer->sem_dispatch;
break;
}
res = sem_getvalue (sem, sem_value);
if (res == -1) {
return (CS_ERR_LIBRARY);
}
#else
retry_semctl:
sem_value_hold = semctl (control_buffer->semid, sem_id, GETVAL, semun);
if (sem_value_hold == -1 && errno == EINTR) {
goto retry_semctl;
} else
if (sem_value_hold == -1) {
return (CS_ERR_LIBRARY);
}
*sem_value = sem_value_hold;
#endif
return (CS_OK);
}
#endif /* COROIPC_IPC_H_DEFINED */

View File

@ -1,49 +0,0 @@
/*
* Copyright (c) 2009 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Steven Dake (sdake@redhat.com)
*
* This software licensed under BSD license, the text of which follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the MontaVista Software, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef COROIPC_TYPES_H_DEFINED
#define COROIPC_TYPES_H_DEFINED
typedef struct {
int size __attribute__((aligned(8)));
int id __attribute__((aligned(8)));
} coroipc_request_header_t __attribute__((aligned(8)));
typedef struct {
int size __attribute__((aligned(8)));
int id __attribute__((aligned(8)));
cs_error_t error __attribute__((aligned(8)));
} coroipc_response_header_t __attribute__((aligned(8)));
#endif /* COROIPC_TYPES_H_DEFINED */

View File

@ -1,124 +0,0 @@
/*
* Copyright (c) 2002-2003 MontaVista Software, Inc.
* Copyright (c) 2006-2007, 2009 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Steven Dake (sdake@redhat.com)
*
* This software licensed under BSD license, the text of which follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the MontaVista Software, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef COROIPCC_H_DEFINED
#define COROIPCC_H_DEFINED
#include <pthread.h>
#include <sys/poll.h>
#include <sys/socket.h>
#include <corosync/corotypes.h>
#include <corosync/hdb.h>
#ifdef __cplusplus
extern "C" {
#endif
extern cs_error_t
coroipcc_service_connect (
const char *socket_name,
unsigned int service,
size_t request_size,
size_t respnse__size,
size_t dispatch_size,
hdb_handle_t *handle);
extern cs_error_t
coroipcc_service_disconnect (
hdb_handle_t handle);
extern cs_error_t
coroipcc_fd_get (
hdb_handle_t handle,
int *fd);
extern cs_error_t
coroipcc_dispatch_get (
hdb_handle_t handle,
void **buf,
int timeout);
extern cs_error_t
coroipcc_dispatch_put (
hdb_handle_t handle);
extern cs_error_t
coroipcc_dispatch_flow_control_get (
hdb_handle_t handle,
unsigned int *flow_control_state);
extern cs_error_t
coroipcc_msg_send_reply_receive (
hdb_handle_t handle,
const struct iovec *iov,
unsigned int iov_len,
void *res_msg,
size_t res_len);
extern cs_error_t
coroipcc_msg_send_reply_receive_in_buf_get (
hdb_handle_t handle,
const struct iovec *iov,
unsigned int iov_len,
void **res_msg);
extern cs_error_t
coroipcc_msg_send_reply_receive_in_buf_put (
hdb_handle_t handle);
extern cs_error_t
coroipcc_zcb_alloc (
hdb_handle_t handle,
void **buffer,
size_t size,
size_t header_size);
extern cs_error_t
coroipcc_zcb_free (
hdb_handle_t handle,
void *buffer);
extern cs_error_t
coroipcc_zcb_msg_send_reply_receive (
hdb_handle_t handle,
void *msg,
void *res_msg,
size_t res_len);
#ifdef __cplusplus
}
#endif
#endif /* COROIPCC_H_DEFINED */

View File

@ -1,171 +0,0 @@
/*
* Copyright (c) 2006-2009 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Steven Dake (sdake@redhat.com)
*
* This software licensed under BSD license, the text of which follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the MontaVista Software, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef COROIPCS_H_DEFINED
#define COROIPCS_H_DEFINED
#include <stdlib.h>
#include <corosync/engine/objdb.h>
#ifdef __cplusplus
extern "C" {
#endif
struct iovec;
typedef int (*coroipcs_init_fn_lvalue) (void *conn);
typedef int (*coroipcs_exit_fn_lvalue) (void *conn);
typedef void (*coroipcs_handler_fn_lvalue) (void *conn, const void *msg);
struct coroipcs_init_state {
const char *socket_name;
int sched_policy;
const struct sched_param *sched_param;
void *(*malloc) (size_t size);
void (*free) (void *ptr);
void (*log_printf) (
const char *format,
...) __attribute__((format(printf, 1, 2)));
int (*service_available)(unsigned int service);
int (*private_data_size_get)(unsigned int service);
int (*security_valid)(int uid, int gid);
void (*serialize_lock)(void);
void (*serialize_unlock)(void);
int (*sending_allowed)(unsigned int service, unsigned int id,
const void *msg, void *sending_allowed_private_data);
void (*sending_allowed_release)(void *sending_allowed_private_data);
void (*poll_accept_add)(int fd);
void (*poll_dispatch_add)(int fd, void *context);
void (*poll_dispatch_modify)(int fd, int events, void *context);
void (*poll_dispatch_destroy)(int fd, void *context);
void (*fatal_error)(const char *error_msg) __attribute__ ((noreturn));
coroipcs_init_fn_lvalue (*init_fn_get)(unsigned int service);
coroipcs_exit_fn_lvalue (*exit_fn_get)(unsigned int service);
coroipcs_handler_fn_lvalue (*handler_fn_get)(unsigned int service, unsigned int id);
};
struct coroipcs_init_state_v2 {
const char *socket_name;
int sched_policy;
const struct sched_param *sched_param;
void *(*malloc) (size_t size);
void (*free) (void *ptr);
void (*old_log_printf) (
const char *format,
...) __attribute__((format(printf, 1, 2)));
int (*service_available)(unsigned int service);
int (*private_data_size_get)(unsigned int service);
int (*security_valid)(int uid, int gid);
void (*serialize_lock)(void);
void (*serialize_unlock)(void);
int (*sending_allowed)(unsigned int service, unsigned int id,
const void *msg, void *sending_allowed_private_data);
void (*sending_allowed_release)(void *sending_allowed_private_data);
void (*poll_accept_add)(int fd);
void (*poll_dispatch_add)(int fd, void *context);
void (*poll_dispatch_modify)(int fd, int events, void *context);
void (*poll_dispatch_destroy)(int fd, void *context);
void (*fatal_error)(const char *error_msg) __attribute__ ((noreturn));
coroipcs_init_fn_lvalue (*init_fn_get)(unsigned int service);
coroipcs_exit_fn_lvalue (*exit_fn_get)(unsigned int service);
coroipcs_handler_fn_lvalue (*handler_fn_get)(unsigned int service, unsigned int id);
/* v2 functions */
hdb_handle_t (*stats_create_connection) (const char* name,
pid_t pid, int fd);
void (*stats_destroy_connection) (hdb_handle_t handle);
void (*stats_update_value) (hdb_handle_t handle,
const char *name, const void *value, size_t value_len);
void (*stats_increment_value) (hdb_handle_t handle, const char* name);
void (*log_printf) (
unsigned int rec_ident,
const char *function_name,
const char *file_name,
int file_line,
const char *format,
...) __attribute__((format(printf, 5, 6)));
int log_subsys_id;
void (*stats_decrement_value) (hdb_handle_t handle, const char* name);
};
extern void coroipcs_ipc_init (
struct coroipcs_init_state *init_state);
extern void coroipcs_ipc_init_v2 (
struct coroipcs_init_state_v2 *init_state_v2);
extern void *coroipcs_private_data_get (void *conn);
extern int coroipcs_response_send (
void *conn,
const void *msg,
size_t mlen);
extern int coroipcs_response_iov_send (
void *conn,
const struct iovec *iov,
unsigned int iov_len);
extern int coroipcs_dispatch_send (
void *conn,
const void *msg,
size_t mlen);
extern int coroipcs_dispatch_iov_send (
void *conn,
const struct iovec *iov,
unsigned int iov_len);
extern void coroipcs_refcount_inc (void *conn);
extern void coroipcs_refcount_dec (void *conn);
extern void coroipcs_ipc_exit (void);
extern int coroipcs_ipc_service_exit (unsigned int service);
extern int coroipcs_handler_accept (
int fd,
int revent,
void *context);
extern int coroipcs_handler_dispatch (
int fd,
int revent,
void *context);
#ifdef __cplusplus
}
#endif
#endif /* COROIPCS_H_DEFINED */

View File

@ -40,6 +40,7 @@
#else
#include <sys/types.h>
#endif
#include <errno.h>
#include <time.h>
#include <sys/time.h>
@ -132,6 +133,82 @@ static inline uint64_t cs_timestamp_get(void)
return result;
}
static inline cs_error_t qb_to_cs_error (int result)
{
int32_t res;
cs_error_t err = CS_ERR_LIBRARY;
if (result >= 0) {
return CS_OK;
}
res = -result;
switch (res) {
case EBADF:
err = CS_ERR_BAD_HANDLE;
break;
case ENOMEM:
err = CS_ERR_NO_MEMORY;
break;
case EAGAIN:
err = CS_ERR_TRY_AGAIN;
break;
case EBADE:
err = CS_ERR_FAILED_OPERATION;
break;
case ETIME:
case ETIMEDOUT:
err = CS_ERR_TIMEOUT;
break;
case EINVAL:
err = CS_ERR_INVALID_PARAM;
break;
case EBUSY:
err = CS_ERR_BUSY;
break;
case EACCES:
err = CS_ERR_ACCESS;
break;
case EOVERFLOW:
err = CS_ERR_NAME_TOO_LONG;
break;
case EEXIST:
err = CS_ERR_EXIST;
break;
case ENOBUFS:
err = CS_ERR_QUEUE_FULL;
break;
case ENOSPC:
err = CS_ERR_NO_SPACE;
break;
case EINTR:
err = CS_ERR_INTERRUPT;
break;
case ENOENT:
case ENODEV:
err = CS_ERR_NOT_EXIST;
break;
case ENOSYS:
case ENOTSUP:
err = CS_ERR_NOT_SUPPORTED;
break;
case EBADMSG:
err = CS_ERR_MESSAGE_ERROR;
break;
case EMSGSIZE:
case E2BIG:
err = CS_ERR_TOO_BIG;
break;
case ECONNREFUSED:
case ENOTCONN:
default:
err = CS_ERR_LIBRARY;
break;
}
return err;
}
/*
* DEPRECATED

View File

@ -75,145 +75,145 @@ enum res_lib_cfg_types {
};
struct req_lib_cfg_statetrack {
coroipc_request_header_t header;
struct qb_ipc_request_header header;
uint8_t track_flags;
corosync_cfg_state_notification_t *notification_buffer_address;
};
struct res_lib_cfg_statetrack {
coroipc_response_header_t header;
struct qb_ipc_response_header header;
};
struct req_lib_cfg_statetrackstop {
coroipc_request_header_t header;
struct qb_ipc_request_header header;
};
struct res_lib_cfg_statetrackstop {
coroipc_response_header_t header;
struct qb_ipc_response_header header;
};
struct req_lib_cfg_administrativestateset {
coroipc_request_header_t header;
struct qb_ipc_request_header header;
cs_name_t comp_name;
corosync_cfg_administrative_target_t administrative_target;
corosync_cfg_administrative_state_t administrative_state;
};
struct res_lib_cfg_administrativestateset {
coroipc_response_header_t header;
struct qb_ipc_response_header header;
};
struct req_lib_cfg_administrativestateget {
coroipc_request_header_t header;
struct qb_ipc_request_header header;
cs_name_t comp_name;
corosync_cfg_administrative_target_t administrative_target;
corosync_cfg_administrative_state_t administrative_state;
};
struct res_lib_cfg_administrativestateget {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
};
struct req_lib_cfg_ringstatusget {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
};
struct res_lib_cfg_ringstatusget {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_uint32_t interface_count __attribute__((aligned(8)));
char interface_name[16][128] __attribute__((aligned(8)));
char interface_status[16][512] __attribute__((aligned(8)));
};
struct req_lib_cfg_ringreenable {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
};
struct res_lib_cfg_ringreenable {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
};
struct req_lib_cfg_serviceload {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
char service_name[256] __attribute__((aligned(8)));
unsigned int service_ver;
};
struct res_lib_cfg_serviceload {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
};
struct req_lib_cfg_serviceunload {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
char service_name[256] __attribute__((aligned(8)));
unsigned int service_ver;
};
struct res_lib_cfg_serviceunload {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
};
struct req_lib_cfg_killnode {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
unsigned int nodeid __attribute__((aligned(8)));
cs_name_t reason __attribute__((aligned(8)));
};
struct res_lib_cfg_killnode {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
};
struct req_lib_cfg_tryshutdown {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
unsigned int flags;
};
struct res_lib_cfg_tryshutdown {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
};
struct req_lib_cfg_replytoshutdown {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
unsigned int response;
};
struct res_lib_cfg_replytoshutdown {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
};
struct res_lib_cfg_testshutdown {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
unsigned int flags;
};
struct req_lib_cfg_get_node_addrs {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
unsigned int nodeid;
};
struct res_lib_cfg_get_node_addrs {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
unsigned int family;
unsigned int num_addrs;
char addrs[TOTEMIP_ADDRLEN][0];
};
struct req_lib_cfg_local_get {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
};
struct res_lib_cfg_local_get {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_uint32_t local_nodeid __attribute__((aligned(8)));
};
struct req_lib_cfg_crypto_set {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_uint32_t type __attribute__((aligned(8)));
};
struct res_lib_cfg_crypto_set {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
};
typedef enum {

View File

@ -91,50 +91,50 @@ enum res_confdb_types {
struct req_lib_confdb_object_create {
coroipc_request_header_t header __attribute__((aligned(8)));
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 {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_uint64_t object_handle __attribute__((aligned(8)));
};
struct req_lib_confdb_object_destroy {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_uint64_t object_handle __attribute__((aligned(8)));
};
struct req_lib_confdb_object_parent_get {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_uint64_t object_handle __attribute__((aligned(8)));
};
struct res_lib_confdb_object_parent_get {
coroipc_response_header_t header __attribute__((aligned(8)));
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 {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_uint64_t object_handle __attribute__((aligned(8)));
};
struct res_lib_confdb_object_name_get {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_name_t object_name __attribute__((aligned(8)));
};
struct req_lib_confdb_key_create {
coroipc_request_header_t header __attribute__((aligned(8)));
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 {
coroipc_request_header_t header __attribute__((aligned(8)));
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)));
@ -142,14 +142,14 @@ struct req_lib_confdb_key_create_typed {
};
struct req_lib_confdb_key_delete {
coroipc_request_header_t header __attribute__((aligned(8)));
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 {
coroipc_request_header_t header __attribute__((aligned(8)));
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)));
@ -157,92 +157,92 @@ struct req_lib_confdb_key_replace {
};
struct req_lib_confdb_object_find {
coroipc_request_header_t header __attribute__((aligned(8)));
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 {
coroipc_response_header_t header __attribute__((aligned(8)));
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 {
coroipc_request_header_t header __attribute__((aligned(8)));
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 {
coroipc_response_header_t header __attribute__((aligned(8)));
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 {
coroipc_request_header_t header __attribute__((aligned(8)));
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 {
coroipc_response_header_t header __attribute__((aligned(8)));
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 {
coroipc_response_header_t header __attribute__((aligned(8)));
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 {
coroipc_request_header_t header __attribute__((aligned(8)));
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 {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_uint64_t find_handle __attribute__((aligned(8)));
};
struct res_lib_confdb_key_get {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_name_t value __attribute__((aligned(8)));
};
struct res_lib_confdb_key_get_typed {
coroipc_response_header_t header __attribute__((aligned(8)));
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 {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_uint32_t value __attribute__((aligned(8)));
};
struct res_lib_confdb_write {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_name_t error __attribute__((aligned(8)));
};
struct req_lib_confdb_reload {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_int32_t flush __attribute__((aligned(8)));
};
struct res_lib_confdb_reload {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_name_t error __attribute__((aligned(8)));
};
struct res_lib_confdb_key_change_callback {
coroipc_response_header_t header __attribute__((aligned(8)));
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)));
@ -252,25 +252,25 @@ struct res_lib_confdb_key_change_callback {
};
struct res_lib_confdb_object_create_callback {
coroipc_response_header_t header __attribute__((aligned(8)));
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 {
coroipc_response_header_t header __attribute__((aligned(8)));
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 {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_uint32_t type __attribute__((aligned(8)));
};
struct req_lib_confdb_object_track_start {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_uint64_t object_handle __attribute__((aligned(8)));
mar_uint32_t flags __attribute__((aligned(8)));
};

View File

@ -36,6 +36,7 @@
#define IPC_CPG_H_DEFINED
#include <netinet/in.h>
#include <qb/qbipc_common.h>
#include <corosync/corotypes.h>
#include <corosync/mar_gen.h>
@ -48,7 +49,10 @@ enum req_cpg_types {
MESSAGE_REQ_CPG_ITERATIONINITIALIZE = 5,
MESSAGE_REQ_CPG_ITERATIONNEXT = 6,
MESSAGE_REQ_CPG_ITERATIONFINALIZE = 7,
MESSAGE_REQ_CPG_FINALIZE = 8
MESSAGE_REQ_CPG_FINALIZE = 8,
MESSAGE_REQ_CPG_ZC_ALLOC = 9,
MESSAGE_REQ_CPG_ZC_FREE = 10,
MESSAGE_REQ_CPG_ZC_EXECUTE = 11,
};
enum res_cpg_types {
@ -66,6 +70,9 @@ enum res_cpg_types {
MESSAGE_RES_CPG_ITERATIONFINALIZE = 11,
MESSAGE_RES_CPG_FINALIZE = 12,
MESSAGE_RES_CPG_TOTEM_CONFCHG_CALLBACK = 13,
MESSAGE_RES_CPG_ZC_ALLOC = 14,
MESSAGE_RES_CPG_ZC_FREE = 15,
MESSAGE_RES_CPG_ZC_EXECUTE = 16,
};
enum lib_cpg_confchg_reason {
@ -164,69 +171,69 @@ static inline void marshall_from_mar_cpg_ring_id_t (
}
struct req_lib_cpg_join {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_cpg_name_t group_name __attribute__((aligned(8)));
mar_uint32_t pid __attribute__((aligned(8)));
mar_uint32_t flags __attribute__((aligned(8)));
};
struct res_lib_cpg_join {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
};
struct req_lib_cpg_finalize {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
};
struct res_lib_cpg_finalize {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
};
struct req_lib_cpg_trackstart {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_cpg_name_t group_name __attribute__((aligned(8)));
mar_uint32_t pid __attribute__((aligned(8)));
};
struct res_lib_cpg_trackstart {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
};
struct req_lib_cpg_trackstop {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_cpg_name_t group_name __attribute__((aligned(8)));
mar_uint32_t pid __attribute__((aligned(8)));
};
struct res_lib_cpg_trackstop {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
};
struct req_lib_cpg_local_get {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
};
struct res_lib_cpg_local_get {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_uint32_t local_nodeid __attribute__((aligned(8)));
};
struct req_lib_cpg_mcast {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_uint32_t guarantee __attribute__((aligned(8)));
mar_uint32_t msglen __attribute__((aligned(8)));
mar_uint8_t message[] __attribute__((aligned(8)));
};
struct res_lib_cpg_mcast {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
};
/**
* Message from another node
*/
struct res_lib_cpg_deliver_callback {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_cpg_name_t group_name __attribute__((aligned(8)));
mar_uint32_t msglen __attribute__((aligned(8)));
mar_uint32_t nodeid __attribute__((aligned(8)));
@ -235,23 +242,23 @@ struct res_lib_cpg_deliver_callback {
};
struct res_lib_cpg_flowcontrol_callback {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_uint32_t flow_control_state __attribute__((aligned(8)));
};
struct req_lib_cpg_membership_get {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_cpg_name_t group_name __attribute__((aligned(8)));
};
struct res_lib_cpg_membership_get {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_uint32_t member_count __attribute__((aligned(8)));
mar_cpg_address_t member_list[PROCESSOR_COUNT_MAX];
};
struct res_lib_cpg_confchg_callback {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_cpg_name_t group_name __attribute__((aligned(8)));
mar_uint32_t member_list_entries __attribute__((aligned(8)));
mar_uint32_t joined_list_entries __attribute__((aligned(8)));
@ -262,50 +269,71 @@ struct res_lib_cpg_confchg_callback {
};
struct res_lib_cpg_totem_confchg_callback {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_cpg_ring_id_t ring_id __attribute__((aligned(8)));
mar_uint32_t member_list_entries __attribute__((aligned(8)));
mar_uint32_t member_list[];
};
struct req_lib_cpg_leave {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_cpg_name_t group_name __attribute__((aligned(8)));
mar_uint32_t pid __attribute__((aligned(8)));
};
struct res_lib_cpg_leave {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
};
struct req_lib_cpg_iterationinitialize {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_cpg_name_t group_name __attribute__((aligned(8)));
mar_uint32_t iteration_type __attribute__((aligned(8)));
};
struct res_lib_cpg_iterationinitialize {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
hdb_handle_t iteration_handle __attribute__((aligned(8)));
};
struct req_lib_cpg_iterationnext {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
hdb_handle_t iteration_handle __attribute__((aligned(8)));
};
struct res_lib_cpg_iterationnext {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_cpg_iteration_description_t description __attribute__((aligned(8)));
};
struct req_lib_cpg_iterationfinalize {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
hdb_handle_t iteration_handle __attribute__((aligned(8)));
};
struct res_lib_cpg_iterationfinalize {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
};
typedef struct {
struct qb_ipc_request_header header __attribute__((aligned(8)));
size_t map_size __attribute__((aligned(8)));
char path_to_file[128] __attribute__((aligned(8)));
} mar_req_coroipcc_zc_alloc_t __attribute__((aligned(8)));
typedef struct {
struct qb_ipc_request_header header __attribute__((aligned(8)));
size_t map_size __attribute__((aligned(8)));
uint64_t server_address __attribute__((aligned(8)));
} mar_req_coroipcc_zc_free_t __attribute__((aligned(8)));
typedef struct {
struct qb_ipc_request_header header __attribute__((aligned(8)));
uint64_t server_address __attribute__((aligned(8)));
} mar_req_coroipcc_zc_execute_t __attribute__((aligned(8)));
struct coroipcs_zc_header {
int map_size;
uint64_t server_address;
};
#endif /* IPC_CPG_H_DEFINED */

View File

@ -36,6 +36,7 @@
#include <inttypes.h>
#include <corosync/corotypes.h>
#include <qb/qbipc_common.h>
#include <corosync/mar_gen.h>
enum req_lib_evs_types {
@ -57,14 +58,14 @@ enum res_lib_evs_types {
};
struct res_evs_deliver_callback {
coroipc_response_header_t header;
struct qb_ipc_response_header header;
unsigned int local_nodeid;
size_t msglen;
char msg[0];
};
struct res_evs_confchg_callback {
coroipc_response_header_t header;
struct qb_ipc_response_header header;
size_t member_list_entries;
size_t left_list_entries;
size_t joined_list_entries;
@ -74,38 +75,38 @@ struct res_evs_confchg_callback {
};
struct req_lib_evs_join {
coroipc_response_header_t header;
struct qb_ipc_response_header header;
size_t group_entries;
struct evs_group groups[0];
};
struct res_lib_evs_join {
coroipc_response_header_t header;
struct qb_ipc_response_header header;
};
struct req_lib_evs_leave {
coroipc_response_header_t header;
struct qb_ipc_response_header header;
size_t group_entries;
struct evs_group groups[0];
};
struct res_lib_evs_leave {
coroipc_response_header_t header;
struct qb_ipc_response_header header;
};
struct req_lib_evs_mcast_joined {
coroipc_response_header_t header;
struct qb_ipc_response_header header;
evs_guarantee_t guarantee;
size_t msg_len;
char msg[0];
};
struct res_lib_evs_mcast_joined {
coroipc_response_header_t header;
struct qb_ipc_response_header header;
};
struct req_lib_evs_mcast_groups {
coroipc_response_header_t header;
struct qb_ipc_response_header header;
evs_guarantee_t guarantee;
size_t msg_len;
size_t group_entries;
@ -113,12 +114,12 @@ struct req_lib_evs_mcast_groups {
};
struct res_lib_evs_mcast_groups {
coroipc_response_header_t header;
struct qb_ipc_response_header header;
};
struct req_exec_evs_mcast {
coroipc_request_header_t header;
struct qb_ipc_request_header header;
size_t group_entries;
size_t msg_len;
struct evs_group groups[0];
@ -126,11 +127,11 @@ struct req_exec_evs_mcast {
};
struct req_lib_evs_membership_get {
coroipc_request_header_t header;
struct qb_ipc_request_header header;
};
struct res_lib_evs_membership_get {
coroipc_response_header_t header;
struct qb_ipc_response_header header;
unsigned int local_nodeid;
unsigned int member_list[PROCESSOR_COUNT_MAX];
size_t member_list_entries;

View File

@ -46,16 +46,16 @@ enum res_lib_evs_types {
};
struct res_lib_pload_start {
coroipc_response_header_t header;
struct qb_ipc_response_header header;
unsigned int dataset[1024];
};
struct res_lib_pload_mcast {
coroipc_response_header_t header;
struct qb_ipc_response_header header;
};
struct req_lib_pload_start {
coroipc_request_header_t header;
struct qb_ipc_request_header header;
unsigned int msg_code;
unsigned int msg_size;
unsigned int msg_count;
@ -63,7 +63,7 @@ struct req_lib_pload_start {
};
struct req_lib_pload_mcast {
coroipc_request_header_t header;
struct qb_ipc_request_header header;
unsigned int code;
};

View File

@ -51,18 +51,18 @@ enum res_quorum_types {
};
struct req_lib_quorum_trackstart {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
unsigned int track_flags;
};
struct res_lib_quorum_getquorate {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_uint32_t quorate;
};
struct res_lib_quorum_notification {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_int32_t quorate __attribute__((aligned(8)));
mar_uint64_t ring_seq __attribute__((aligned(8)));
mar_uint32_t view_list_entries __attribute__((aligned(8)));

View File

@ -62,35 +62,35 @@ enum res_votequorum_types {
};
struct req_lib_votequorum_setvotes {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
unsigned int votes;
int nodeid;
};
struct req_lib_votequorum_qdisk_register {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
unsigned int votes;
char name[VOTEQUORUM_MAX_QDISK_NAME_LEN];
};
struct req_lib_votequorum_qdisk_poll {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
int state;
};
struct req_lib_votequorum_setexpected {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
unsigned int expected_votes;
};
struct req_lib_votequorum_trackstart {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
uint64_t context;
unsigned int track_flags;
};
struct req_lib_votequorum_general {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
};
#define VOTEQUORUM_REASON_KILL_REJECTED 1
@ -98,12 +98,12 @@ struct req_lib_votequorum_general {
#define VOTEQUORUM_REASON_KILL_REJOIN 3
struct req_lib_votequorum_getinfo {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
int nodeid;
};
struct res_lib_votequorum_status {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
};
#define VOTEQUORUM_INFO_FLAG_HASSTATE 1
@ -112,7 +112,7 @@ struct res_lib_votequorum_status {
#define VOTEQUORUM_INFO_FLAG_QUORATE 8
struct res_lib_votequorum_getinfo {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
int nodeid;
unsigned int votes;
unsigned int expected_votes;
@ -123,7 +123,7 @@ struct res_lib_votequorum_getinfo {
};
struct res_lib_votequorum_qdisk_getinfo {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
unsigned int votes;
unsigned int state;
char name[VOTEQUORUM_MAX_QDISK_NAME_LEN];
@ -135,7 +135,7 @@ struct votequorum_node {
};
struct res_lib_votequorum_notification {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_uint32_t quorate __attribute__((aligned(8)));
mar_uint64_t context __attribute__((aligned(8)));
mar_uint32_t node_list_entries __attribute__((aligned(8)));
@ -143,7 +143,7 @@ struct res_lib_votequorum_notification {
};
struct res_lib_votequorum_expectedvotes_notification {
coroipc_response_header_t header __attribute__((aligned(8)));
struct qb_ipc_response_header header __attribute__((aligned(8)));
mar_uint64_t context __attribute__((aligned(8)));
mar_uint32_t expected_votes __attribute__((aligned(8)));
};

View File

@ -178,7 +178,7 @@ static inline void swab_mar_size_t (mar_size_t *to_swab)
swab_mar_uint64_t (to_swab);
}
static inline void swab_coroipc_request_header_t (coroipc_request_header_t *to_swab)
static inline void swab_coroipc_request_header_t (struct qb_ipc_request_header *to_swab)
{
swab_mar_int32_t (&to_swab->size);
swab_mar_int32_t (&to_swab->id);

View File

@ -170,6 +170,19 @@ extern int totempg_member_remove (
const struct totem_ip_address *member,
int ring_no);
enum totem_q_level {
TOTEM_Q_LEVEL_LOW,
TOTEM_Q_LEVEL_GOOD,
TOTEM_Q_LEVEL_HIGH,
TOTEM_Q_LEVEL_CRITICAL
};
void totempg_check_q_level(hdb_handle_t handle);
typedef void (*totem_queue_level_changed_fn) (enum totem_q_level level);
extern void totempg_queue_level_register_callback (totem_queue_level_changed_fn);
#ifdef __cplusplus
}
#endif

View File

@ -31,6 +31,7 @@
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <dirent.h>
#include <errno.h>
@ -43,8 +44,6 @@
#include <corosync/hdb.h>
#include <corosync/lcr/lcr_comp.h>
#include <corosync/lcr/lcr_ifact.h>
#include <corosync/hdb.h>
#include <stdlib.h>
struct lcr_component_instance {
struct lcr_iface *ifaces;

View File

@ -36,8 +36,6 @@ get_soname=$(if $($(call uc,$1)_SONAME),$($(call uc,$1)_SONAME),$(SONAME))
get_major=$(firstword $(subst ., ,$(call get_soname,$1)))
get_sharedlibs=$(foreach lib,$(SHARED_LIBS_SO:lib%.so=%),lib$(lib).so.$(call get_soname,$(lib)))
get_sharedlibs_two=$(foreach lib,$(SHARED_LIBS_SO:lib%.so=%),lib$(lib).so.$(call get_major,$(lib)))
get_explicit_sharedlibs=$(foreach lib,$(EXPLICIT_SHARED_LIBS_SO:lib%.so=%),lib$(lib).so.$(call get_soname,$(lib)))
get_explicit_sharedlibs_two=$(foreach lib,$(EXPLICIT_SHARED_LIBS_SO:lib%.so=%),lib$(lib).so.$(call get_major,$(lib)))
get_linker_add=$(if $($(call uc,$1)_LINKER_ADD),$($(call uc,$1)_LINKER_ADD))
MAINTAINERCLEANFILES = Makefile.in
@ -48,10 +46,9 @@ AM_LDFLAGS = -lpthread
INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
lib_LIBRARIES = libcpg.a libconfdb.a libevs.a libcfg.a libquorum.a \
libvotequorum.a libpload.a libcoroipcc.a libsam.a
SHARED_LIBS_SO = $(filter-out $(EXPLICIT_SHARED_LIBS_SO), $(lib_LIBRARIES:%.a=%.so))
EXPLICIT_SHARED_LIBS_SO = libcoroipcc.so
lib_LIBRARIES = libcpg.a libconfdb.a libquorum.a libevs.a libcfg.a \
libvotequorum.a libpload.a libsam.a
SHARED_LIBS_SO = $(lib_LIBRARIES:%.a=%.so)
libcpg_a_SOURCES = cpg.c
libcfg_a_SOURCES = cfg.c
@ -63,12 +60,11 @@ 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
libcoroipcc_a_SOURCES = coroipcc.c
libsam_a_SOURCES = sam.c
noinst_HEADERS = sa-confdb.h util.h \
libcfg.versions libconfdb.versions \
libcoroipcc.versions libcpg.versions \
libcpg.versions \
libevs.versions libpload.versions \
libquorum.versions libvotequorum.versions \
libsam.versions
@ -78,12 +74,7 @@ noinst_HEADERS = sa-confdb.h util.h \
if BUILD_DARWIN
libcoroipcc.so.$(SONAME): coroipcc.o
$(CC) $(LDFLAGS) $(DARWIN_OPTS) coroipcc.o -o $@ $(AM_LDFLAGS)
ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so
ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so.$(SOMAJOR)
lib%.so: lib%.a libcoroipcc.so.$(SONAME)
lib%.so: lib%.a $(LIBQB_LIBS)
$(CC) $(DARWIN_OPTS) $(call get_linker_add,$*) -Wl,-whole-archive $^ -Wl,-no-whole-archive -o $@
ln -sf lib$*.so.$(call get_soname,$*) lib$*.so
ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*)
@ -92,35 +83,20 @@ else
if BUILD_SOLARIS
libcoroipcc.so.$(SONAME): coroipcc.o
$(LD) $(LDFLAGS) $(SOLARIS_OPTS) -G coroipcc.o -o $@ $(AM_LDFLAGS) -lsocket -lnsl
ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so
ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so.$(SOMAJOR)
lib%.so.$(SONAME): lib%.a libcoroipcc.so.$(SONAME)
lib%.so.$(SONAME): lib%.a
$(LD) $(SOLARIS_OPTS) $(call get_linker_add,$*) -G -whole-archive $^ -no-whole-archive -o $@
ln -sf lib$*.so.$(call get_soname,$*) lib$*.so
ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*)
else
libcoroipcc.so.$(SONAME): coroipcc.o
$(CC) -shared -o $@ \
-Wl,-soname=libcoroipcc.so.$(SOMAJOR) \
-Wl,-version-script=$(srcdir)/libcoroipcc.versions \
$(LDFLAGS) $^ $(AM_LDFLAGS)
ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so
ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so.$(SOMAJOR)
lib%.so: lib%.a libcoroipcc.so.$(SONAME)
if [ ! "$@" = "libcoroipcc.so" ] ; then \
lib%.so: lib%.a
$(CC) -shared -o $@.$(call get_soname,$*) \
-Wl,-soname=lib$*.so.$(call get_major,$*) \
-Wl,-version-script=$(srcdir)/lib$*.versions \
-Wl,-whole-archive $^ -Wl,-no-whole-archive $(LDFLAGS) $(AM_LDFLAGS) $(call get_linker_add,$*) ;\
ln -sf lib$*.so.$(call get_soname,$*) lib$*.so ;\
ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*) ;\
fi
-Wl,-whole-archive $^ -Wl,-no-whole-archive $(LDFLAGS) $(LIBQB_LIBS) $(AM_LDFLAGS) $(call get_linker_add,$*)
ln -sf lib$*.so.$(call get_soname,$*) lib$*.so
ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*)
endif
@ -131,8 +107,8 @@ all-local: $(get_explicit_sharedlibs) $(SHARED_LIBS_SO)
install-exec-local:
$(INSTALL) -d $(DESTDIR)/$(libdir)
$(INSTALL) -m 755 $(get_sharedlibs) $(get_explicit_sharedlibs) $(DESTDIR)/$(libdir)
$(CP) -a $(SHARED_LIBS_SO) $(EXPLICIT_SHARED_LIBS_SO) $(get_sharedlibs_two) $(get_explicit_sharedlibs_two) $(DESTDIR)/$(libdir)
$(INSTALL) -m 755 $(get_sharedlibs) $(DESTDIR)/$(libdir)
$(CP) -a $(SHARED_LIBS_SO) $(get_sharedlibs_two) $(DESTDIR)/$(libdir)
uninstall-local:
cd $(DESTDIR)/$(libdir)/ && \

173
lib/cfg.c
View File

@ -47,9 +47,9 @@
#include <sys/select.h>
#include <sys/un.h>
#include <qb/qbipcc.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <corosync/coroipcc.h>
#include <corosync/corodefs.h>
#include <corosync/hdb.h>
@ -61,8 +61,8 @@
/*
* Data structure for instance data
*/
struct cfg_instance {
hdb_handle_t handle;
struct cfg_inst {
qb_ipcc_connection_t *c;
corosync_cfg_callbacks_t callbacks;
cs_name_t comp_name;
int comp_registered;
@ -83,32 +83,30 @@ corosync_cfg_initialize (
corosync_cfg_handle_t *cfg_handle,
const corosync_cfg_callbacks_t *cfg_callbacks)
{
struct cfg_instance *cfg_instance;
struct cfg_inst *cfg_inst;
cs_error_t error = CS_OK;
error = hdb_error_to_cs (hdb_handle_create (&cfg_hdb, sizeof (struct cfg_instance), cfg_handle));
error = hdb_error_to_cs (hdb_handle_create (&cfg_hdb, sizeof (struct cfg_inst), cfg_handle));
if (error != CS_OK) {
goto error_no_destroy;
}
error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, *cfg_handle, (void *)&cfg_instance));
error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, *cfg_handle, (void *)&cfg_inst));
if (error != CS_OK) {
goto error_destroy;
}
error = coroipcc_service_connect (
COROSYNC_SOCKET_NAME,
CFG_SERVICE,
IPC_REQUEST_SIZE,
IPC_RESPONSE_SIZE,
IPC_DISPATCH_SIZE,
&cfg_instance->handle);
cfg_inst->c = qb_ipcc_connect ("cfg", IPC_REQUEST_SIZE);
if (cfg_inst->c == NULL) {
error = qb_to_cs_error(-errno);
goto error_put_destroy;
}
if (error != CS_OK) {
goto error_put_destroy;
}
if (cfg_callbacks) {
memcpy (&cfg_instance->callbacks, cfg_callbacks, sizeof (corosync_cfg_callbacks_t));
memcpy (&cfg_inst->callbacks, cfg_callbacks, sizeof (corosync_cfg_callbacks_t));
}
(void)hdb_handle_put (&cfg_hdb, *cfg_handle);
@ -128,15 +126,15 @@ corosync_cfg_fd_get (
corosync_cfg_handle_t cfg_handle,
int32_t *selection_fd)
{
struct cfg_instance *cfg_instance;
struct cfg_inst *cfg_inst;
cs_error_t error;
error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_instance));
error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst));
if (error != CS_OK) {
return (error);
}
error = coroipcc_fd_get (cfg_instance->handle, selection_fd);
error = qb_to_cs_error (qb_ipcc_fd_get (cfg_inst->c, selection_fd));
(void)hdb_handle_put (&cfg_hdb, cfg_handle);
return (error);
@ -150,13 +148,14 @@ corosync_cfg_dispatch (
int timeout = -1;
cs_error_t error;
int cont = 1; /* always continue do loop except when set to 0 */
struct cfg_instance *cfg_instance;
struct cfg_inst *cfg_inst;
struct res_lib_cfg_testshutdown *res_lib_cfg_testshutdown;
corosync_cfg_callbacks_t callbacks;
coroipc_response_header_t *dispatch_data;
struct qb_ipc_response_header *dispatch_data;
char dispatch_buf[IPC_DISPATCH_SIZE];
error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle,
(void *)&cfg_instance));
(void *)&cfg_inst));
if (error != CS_OK) {
return (error);
}
@ -168,12 +167,13 @@ corosync_cfg_dispatch (
timeout = 0;
}
dispatch_data = (struct qb_ipc_response_header *)dispatch_buf;
do {
error = coroipcc_dispatch_get (
cfg_instance->handle,
(void **)&dispatch_data,
timeout);
error = qb_to_cs_error (qb_ipcc_event_recv (
cfg_inst->c,
dispatch_buf,
IPC_DISPATCH_SIZE,
timeout));
if (error == CS_ERR_BAD_HANDLE) {
error = CS_OK;
goto error_put;
@ -195,7 +195,7 @@ corosync_cfg_dispatch (
* A risk of this dispatch method is that the callback routines may
* operate at the same time that cfgFinalize has been called in another thread.
*/
memcpy (&callbacks, &cfg_instance->callbacks, sizeof (corosync_cfg_callbacks_t));
memcpy (&callbacks, &cfg_inst->callbacks, sizeof (corosync_cfg_callbacks_t));
/*
* Dispatch incoming response
@ -210,12 +210,10 @@ corosync_cfg_dispatch (
callbacks.corosync_cfg_shutdown_callback(cfg_handle, res_lib_cfg_testshutdown->flags);
break;
default:
coroipcc_dispatch_put (cfg_instance->handle);
error = CS_ERR_LIBRARY;
goto error_nounlock;
break;
}
coroipcc_dispatch_put (cfg_instance->handle);
/*
* Determine if more messages should be processed
@ -235,10 +233,10 @@ cs_error_t
corosync_cfg_finalize (
corosync_cfg_handle_t cfg_handle)
{
struct cfg_instance *cfg_instance;
struct cfg_inst *cfg_inst;
cs_error_t error;
error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_instance));
error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst));
if (error != CS_OK) {
return (error);
}
@ -246,14 +244,14 @@ corosync_cfg_finalize (
/*
* Another thread has already started finalizing
*/
if (cfg_instance->finalize) {
if (cfg_inst->finalize) {
(void)hdb_handle_put (&cfg_hdb, cfg_handle);
return (CS_ERR_BAD_HANDLE);
}
cfg_instance->finalize = 1;
cfg_inst->finalize = 1;
coroipcc_service_disconnect (cfg_instance->handle);
qb_ipcc_disconnect (cfg_inst->c);
(void)hdb_handle_destroy (&cfg_hdb, cfg_handle);
@ -269,14 +267,14 @@ corosync_cfg_ring_status_get (
char ***status,
unsigned int *interface_count)
{
struct cfg_instance *cfg_instance;
struct cfg_inst *cfg_inst;
struct req_lib_cfg_ringstatusget req_lib_cfg_ringstatusget;
struct res_lib_cfg_ringstatusget res_lib_cfg_ringstatusget;
unsigned int i, j;
cs_error_t error;
struct iovec iov;
error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_instance));
error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst));
if (error != CS_OK) {
return (error);
}
@ -287,11 +285,11 @@ corosync_cfg_ring_status_get (
iov.iov_base = (void *)&req_lib_cfg_ringstatusget,
iov.iov_len = sizeof (struct req_lib_cfg_ringstatusget),
error = coroipcc_msg_send_reply_receive(cfg_instance->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv(cfg_inst->c,
&iov,
1,
&res_lib_cfg_ringstatusget,
sizeof (struct res_lib_cfg_ringstatusget));
sizeof (struct res_lib_cfg_ringstatusget), -1));
*interface_count = res_lib_cfg_ringstatusget.interface_count;
*interface_names = malloc (sizeof (char *) * *interface_count);
@ -350,13 +348,13 @@ cs_error_t
corosync_cfg_ring_reenable (
corosync_cfg_handle_t cfg_handle)
{
struct cfg_instance *cfg_instance;
struct cfg_inst *cfg_inst;
struct req_lib_cfg_ringreenable req_lib_cfg_ringreenable;
struct res_lib_cfg_ringreenable res_lib_cfg_ringreenable;
cs_error_t error;
struct iovec iov;
error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_instance));
error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst));
if (error != CS_OK) {
return (error);
}
@ -367,11 +365,11 @@ corosync_cfg_ring_reenable (
iov.iov_base = (void *)&req_lib_cfg_ringreenable,
iov.iov_len = sizeof (struct req_lib_cfg_ringreenable);
error = coroipcc_msg_send_reply_receive (cfg_instance->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c,
&iov,
1,
&res_lib_cfg_ringreenable,
sizeof (struct res_lib_cfg_ringreenable));
sizeof (struct res_lib_cfg_ringreenable), -1));
(void)hdb_handle_put (&cfg_hdb, cfg_handle);
@ -384,13 +382,13 @@ corosync_cfg_service_load (
const char *service_name,
unsigned int service_ver)
{
struct cfg_instance *cfg_instance;
struct cfg_inst *cfg_inst;
struct req_lib_cfg_serviceload req_lib_cfg_serviceload;
struct res_lib_cfg_serviceload res_lib_cfg_serviceload;
cs_error_t error;
struct iovec iov;
error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_instance));
error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst));
if (error != CS_OK) {
return (error);
}
@ -406,11 +404,11 @@ corosync_cfg_service_load (
iov.iov_base = (void *)&req_lib_cfg_serviceload;
iov.iov_len = sizeof (req_lib_cfg_serviceload);
error = coroipcc_msg_send_reply_receive (cfg_instance->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c,
&iov,
1,
&res_lib_cfg_serviceload,
sizeof (struct res_lib_cfg_serviceload));
sizeof (struct res_lib_cfg_serviceload), -1));
(void)hdb_handle_put (&cfg_hdb, cfg_handle);
@ -423,13 +421,13 @@ corosync_cfg_service_unload (
const char *service_name,
unsigned int service_ver)
{
struct cfg_instance *cfg_instance;
struct cfg_inst *cfg_inst;
struct req_lib_cfg_serviceunload req_lib_cfg_serviceunload;
struct res_lib_cfg_serviceunload res_lib_cfg_serviceunload;
cs_error_t error;
struct iovec iov;
error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_instance));
error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle, (void *)&cfg_inst));
if (error != CS_OK) {
return (error);
}
@ -445,11 +443,11 @@ corosync_cfg_service_unload (
iov.iov_base = (void *)&req_lib_cfg_serviceunload;
iov.iov_len = sizeof (req_lib_cfg_serviceunload);
error = coroipcc_msg_send_reply_receive (cfg_instance->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c,
&iov,
1,
&res_lib_cfg_serviceunload,
sizeof (struct res_lib_cfg_serviceunload));
sizeof (struct res_lib_cfg_serviceunload), -1));
(void)hdb_handle_put (&cfg_hdb, cfg_handle);
@ -461,7 +459,7 @@ corosync_cfg_state_track (
uint8_t track_flags,
const corosync_cfg_state_notification_t *notification_buffer)
{
struct cfg_instance *cfg_instance;
struct cfg_inst *cfg_inst;
struct req_lib_cfg_statetrack req_lib_cfg_statetrack;
struct res_lib_cfg_statetrack res_lib_cfg_statetrack;
cs_error_t error;
@ -473,7 +471,7 @@ corosync_cfg_state_track (
req_lib_cfg_statetrack.notification_buffer_address = (corosync_cfg_state_notification_t *)notification_buffer;
error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle,
(void *)&cfg_instance));
(void *)&cfg_inst));
if (error != CS_OK) {
return (error);
}
@ -481,11 +479,11 @@ corosync_cfg_state_track (
iov.iov_base = (void *)&req_lib_cfg_statetrack,
iov.iov_len = sizeof (struct req_lib_cfg_statetrack),
error = coroipcc_msg_send_reply_receive (cfg_instance->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c,
&iov,
1,
&res_lib_cfg_statetrack,
sizeof (struct res_lib_cfg_statetrack));
sizeof (struct res_lib_cfg_statetrack), -1));
(void)hdb_handle_put (&cfg_hdb, cfg_handle);
@ -496,14 +494,14 @@ cs_error_t
corosync_cfg_state_track_stop (
corosync_cfg_handle_t cfg_handle)
{
struct cfg_instance *cfg_instance;
struct cfg_inst *cfg_inst;
struct req_lib_cfg_statetrackstop req_lib_cfg_statetrackstop;
struct res_lib_cfg_statetrackstop res_lib_cfg_statetrackstop;
cs_error_t error;
struct iovec iov;
error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle,
(void *)&cfg_instance));
(void *)&cfg_inst));
if (error != CS_OK) {
return (error);
}
@ -514,11 +512,11 @@ corosync_cfg_state_track_stop (
iov.iov_base = (void *)&req_lib_cfg_statetrackstop,
iov.iov_len = sizeof (struct req_lib_cfg_statetrackstop),
error = coroipcc_msg_send_reply_receive (cfg_instance->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c,
&iov,
1,
&res_lib_cfg_statetrackstop,
sizeof (struct res_lib_cfg_statetrackstop));
sizeof (struct res_lib_cfg_statetrackstop), -1));
(void)hdb_handle_put (&cfg_hdb, cfg_handle);
@ -531,7 +529,7 @@ corosync_cfg_kill_node (
unsigned int nodeid,
const char *reason)
{
struct cfg_instance *cfg_instance;
struct cfg_inst *cfg_inst;
struct req_lib_cfg_killnode req_lib_cfg_killnode;
struct res_lib_cfg_killnode res_lib_cfg_killnode;
cs_error_t error;
@ -541,7 +539,7 @@ corosync_cfg_kill_node (
return CS_ERR_NAME_TOO_LONG;
error = hdb_error_to_cs (hdb_handle_get (&cfg_hdb, cfg_handle,
(void *)&cfg_instance));
(void *)&cfg_inst));
if (error != CS_OK) {
return (error);
}
@ -555,11 +553,11 @@ corosync_cfg_kill_node (
iov.iov_base = (void *)&req_lib_cfg_killnode;
iov.iov_len = sizeof (struct req_lib_cfg_killnode);
error = coroipcc_msg_send_reply_receive (cfg_instance->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c,
&iov,
1,
&res_lib_cfg_killnode,
sizeof (struct res_lib_cfg_killnode));
sizeof (struct res_lib_cfg_killnode), -1));
error = res_lib_cfg_killnode.header.error;
@ -573,14 +571,14 @@ corosync_cfg_try_shutdown (
corosync_cfg_handle_t cfg_handle,
corosync_cfg_shutdown_flags_t flags)
{
struct cfg_instance *cfg_instance;
struct cfg_inst *cfg_inst;
struct req_lib_cfg_tryshutdown req_lib_cfg_tryshutdown;
struct res_lib_cfg_tryshutdown res_lib_cfg_tryshutdown;
cs_error_t error;
struct iovec iov;
error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle,
(void *)&cfg_instance));
(void *)&cfg_inst));
if (error != CS_OK) {
return (error);
}
@ -592,11 +590,11 @@ corosync_cfg_try_shutdown (
iov.iov_base = (void *)&req_lib_cfg_tryshutdown;
iov.iov_len = sizeof (req_lib_cfg_tryshutdown);
error = coroipcc_msg_send_reply_receive (cfg_instance->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c,
&iov,
1,
&res_lib_cfg_tryshutdown,
sizeof (struct res_lib_cfg_tryshutdown));
sizeof (struct res_lib_cfg_tryshutdown), -1));
(void)hdb_handle_put (&cfg_hdb, cfg_handle);
@ -608,14 +606,14 @@ corosync_cfg_replyto_shutdown (
corosync_cfg_handle_t cfg_handle,
corosync_cfg_shutdown_reply_flags_t response)
{
struct cfg_instance *cfg_instance;
struct cfg_inst *cfg_inst;
struct req_lib_cfg_replytoshutdown req_lib_cfg_replytoshutdown;
struct res_lib_cfg_replytoshutdown res_lib_cfg_replytoshutdown;
struct iovec iov;
cs_error_t error;
error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle,
(void *)&cfg_instance));
(void *)&cfg_inst));
if (error != CS_OK) {
return (error);
}
@ -627,11 +625,11 @@ corosync_cfg_replyto_shutdown (
iov.iov_base = (void *)&req_lib_cfg_replytoshutdown;
iov.iov_len = sizeof (struct req_lib_cfg_replytoshutdown);
error = coroipcc_msg_send_reply_receive (cfg_instance->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c,
&iov,
1,
&res_lib_cfg_replytoshutdown,
sizeof (struct res_lib_cfg_replytoshutdown));
sizeof (struct res_lib_cfg_replytoshutdown), -1));
return (error);
}
@ -646,15 +644,16 @@ cs_error_t corosync_cfg_get_node_addrs (
cs_error_t error;
struct req_lib_cfg_get_node_addrs req_lib_cfg_get_node_addrs;
struct res_lib_cfg_get_node_addrs *res_lib_cfg_get_node_addrs;
struct cfg_instance *cfg_instance;
struct cfg_inst *cfg_inst;
int addrlen = 0;
int i;
struct iovec iov;
void *return_address;
const char *addr_buf;
char response_buf[IPC_RESPONSE_SIZE];
error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, cfg_handle,
(void *)&cfg_instance));
(void *)&cfg_inst));
if (error != CS_OK) {
return (error);
}
@ -666,12 +665,11 @@ cs_error_t corosync_cfg_get_node_addrs (
iov.iov_base = (char *)&req_lib_cfg_get_node_addrs;
iov.iov_len = sizeof (req_lib_cfg_get_node_addrs);
error = coroipcc_msg_send_reply_receive_in_buf_get (
cfg_instance->handle,
&iov,
1,
&return_address);
res_lib_cfg_get_node_addrs = return_address;
error = qb_to_cs_error (qb_ipcc_sendv_recv (
cfg_inst->c,
&iov, 1,
response_buf, IPC_RESPONSE_SIZE, -1));
res_lib_cfg_get_node_addrs = (struct res_lib_cfg_get_node_addrs *)response_buf;
if (error != CS_OK) {
goto error_put;
@ -705,7 +703,6 @@ cs_error_t corosync_cfg_get_node_addrs (
errno = error = res_lib_cfg_get_node_addrs->header.error;
error_put:
error = coroipcc_msg_send_reply_receive_in_buf_put (cfg_instance->handle);
hdb_handle_put (&cfg_hdb, cfg_handle);
return (error);
@ -716,7 +713,7 @@ cs_error_t corosync_cfg_local_get (
unsigned int *local_nodeid)
{
cs_error_t error;
struct cfg_instance *cfg_inst;
struct cfg_inst *cfg_inst;
struct iovec iov;
struct req_lib_cfg_local_get req_lib_cfg_local_get;
struct res_lib_cfg_local_get res_lib_cfg_local_get;
@ -726,18 +723,18 @@ cs_error_t corosync_cfg_local_get (
return (error);
}
req_lib_cfg_local_get.header.size = sizeof (coroipc_request_header_t);
req_lib_cfg_local_get.header.size = sizeof (struct qb_ipc_request_header);
req_lib_cfg_local_get.header.id = MESSAGE_REQ_CFG_LOCAL_GET;
iov.iov_base = (void *)&req_lib_cfg_local_get;
iov.iov_len = sizeof (struct req_lib_cfg_local_get);
error = coroipcc_msg_send_reply_receive (
cfg_inst->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (
cfg_inst->c,
&iov,
1,
&res_lib_cfg_local_get,
sizeof (struct res_lib_cfg_local_get));
sizeof (struct res_lib_cfg_local_get), -1));
if (error != CS_OK) {
goto error_exit;
@ -758,14 +755,14 @@ corosync_cfg_crypto_set (
corosync_cfg_handle_t handle,
unsigned int type)
{
struct cfg_instance *cfg_instance;
struct cfg_inst *cfg_inst;
struct req_lib_cfg_crypto_set req_lib_cfg_crypto_set;
struct res_lib_cfg_crypto_set res_lib_cfg_crypto_set;
struct iovec iov;
cs_error_t error;
error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, handle, (void *)&cfg_instance));
error = hdb_error_to_cs(hdb_handle_get (&cfg_hdb, handle, (void *)&cfg_inst));
if (error != CS_OK) {
return (error);
}
@ -777,11 +774,11 @@ corosync_cfg_crypto_set (
iov.iov_base = (void *)&req_lib_cfg_crypto_set;
iov.iov_len = sizeof (struct req_lib_cfg_crypto_set);
error = coroipcc_msg_send_reply_receive (cfg_instance->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (cfg_inst->c,
&iov,
1,
&res_lib_cfg_crypto_set,
sizeof (struct res_lib_cfg_crypto_set));
sizeof (struct res_lib_cfg_crypto_set), -1));
if (error == CS_OK)
error = res_lib_cfg_crypto_set.header.error;

View File

@ -45,11 +45,10 @@
#include <errno.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <corosync/coroipcc.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>
@ -58,9 +57,6 @@
#include "sa-confdb.h"
#undef MIN
#define MIN(x,y) ((x) < (y) ? (x) : (y))
/* Hold the information for iterators so that
callers can do recursive tree traversals.
each object_handle can have its own iterator */
@ -72,7 +68,7 @@ struct iter_context {
};
struct confdb_inst {
hdb_handle_t handle;
qb_ipcc_connection_t *c;
int finalize;
int standalone;
confdb_callbacks_t callbacks;
@ -147,13 +143,12 @@ cs_error_t confdb_initialize (
confdb_inst->standalone = 1;
}
else {
error = coroipcc_service_connect (
COROSYNC_SOCKET_NAME,
CONFDB_SERVICE,
IPC_REQUEST_SIZE,
IPC_RESPONSE_SIZE,
IPC_DISPATCH_SIZE,
&confdb_inst->handle);
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;
@ -205,7 +200,7 @@ cs_error_t confdb_finalize (
free_context_list(confdb_inst, &confdb_inst->key_iter_head);
if (!confdb_inst->standalone) {
coroipcc_service_disconnect (confdb_inst->handle);
qb_ipcc_disconnect (confdb_inst->c);
}
(void)hdb_handle_destroy (&confdb_handle_t_db, handle);
@ -227,7 +222,7 @@ cs_error_t confdb_fd_get (
return (error);
}
error = coroipcc_fd_get (confdb_inst->handle, fd);
error = qb_to_cs_error (qb_ipcc_fd_get (confdb_inst->c, fd));
(void)hdb_handle_put (&confdb_handle_t_db, handle);
@ -285,7 +280,8 @@ cs_error_t confdb_dispatch (
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;
coroipc_response_header_t *dispatch_data;
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) {
@ -305,11 +301,13 @@ cs_error_t confdb_dispatch (
timeout = 0;
}
dispatch_data = (struct qb_ipc_response_header *)dispatch_buf;
do {
error = coroipcc_dispatch_get (
confdb_inst->handle,
(void **)&dispatch_data,
timeout);
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;
@ -397,12 +395,10 @@ cs_error_t confdb_dispatch (
break;
default:
coroipcc_dispatch_put (confdb_inst->handle);
error = CS_ERR_LIBRARY;
goto error_noput;
break;
}
coroipcc_dispatch_put (confdb_inst->handle);
/*
* Determine if more messages should be processed
@ -455,12 +451,12 @@ cs_error_t confdb_object_create (
iov.iov_base = (char *)&req_lib_confdb_object_create;
iov.iov_len = sizeof (struct req_lib_confdb_object_create);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
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));
sizeof (struct res_lib_confdb_object_create), -1));
if (error != CS_OK) {
goto error_exit;
@ -483,7 +479,7 @@ cs_error_t confdb_object_destroy (
struct confdb_inst *confdb_inst;
struct iovec iov;
struct req_lib_confdb_object_destroy req_lib_confdb_object_destroy;
coroipc_response_header_t res;
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) {
@ -505,12 +501,12 @@ cs_error_t confdb_object_destroy (
iov.iov_base = (char *)&req_lib_confdb_object_destroy;
iov.iov_len = sizeof (struct req_lib_confdb_object_destroy);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (
confdb_inst->c,
&iov,
1,
&res,
sizeof (coroipc_response_header_t));
sizeof (struct qb_ipc_response_header), -1));
if (error != CS_OK) {
goto error_exit;
@ -555,12 +551,12 @@ cs_error_t confdb_object_parent_get (
iov.iov_base = (char *)&req_lib_confdb_object_parent_get;
iov.iov_len = sizeof (struct req_lib_confdb_object_parent_get);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
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));
sizeof (struct res_lib_confdb_object_parent_get), -1));
if (error != CS_OK) {
goto error_exit;
@ -607,12 +603,12 @@ cs_error_t confdb_object_name_get (
iov.iov_base = (char *)&request;
iov.iov_len = sizeof (struct req_lib_confdb_object_name_get);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (
confdb_inst->c,
&iov,
1,
&response,
sizeof (struct res_lib_confdb_object_name_get));
sizeof (struct res_lib_confdb_object_name_get), -1));
if (error != CS_OK) {
goto error_exit;
@ -637,7 +633,7 @@ static cs_error_t do_find_destroy(
cs_error_t error;
struct iovec iov;
struct req_lib_confdb_object_find_destroy req_lib_confdb_object_find_destroy;
coroipc_response_header_t res;
struct qb_ipc_response_header res;
if (!find_handle)
return CS_OK;
@ -657,12 +653,12 @@ static cs_error_t do_find_destroy(
iov.iov_base = (char *)&req_lib_confdb_object_find_destroy;
iov.iov_len = sizeof (struct req_lib_confdb_object_find_destroy);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (
confdb_inst->c,
&iov,
1,
&res,
sizeof (coroipc_response_header_t));
sizeof (struct qb_ipc_response_header), -1));
if (error != CS_OK) {
goto error_exit;
@ -736,7 +732,7 @@ cs_error_t confdb_key_create (
struct confdb_inst *confdb_inst;
struct iovec iov;
struct req_lib_confdb_key_create req_lib_confdb_key_create;
coroipc_response_header_t res;
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) {
@ -764,12 +760,12 @@ cs_error_t confdb_key_create (
iov.iov_base = (char *)&req_lib_confdb_key_create;
iov.iov_len = sizeof (struct req_lib_confdb_key_create);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (
confdb_inst->c,
&iov,
1,
&res,
sizeof (res));
sizeof (res), -1));
if (error != CS_OK) {
goto error_exit;
@ -796,7 +792,7 @@ cs_error_t confdb_key_create_typed (
struct confdb_inst *confdb_inst;
struct iovec iov;
struct req_lib_confdb_key_create_typed request;
coroipc_response_header_t res;
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) {
@ -824,12 +820,12 @@ cs_error_t confdb_key_create_typed (
iov.iov_base = (char *)&request;
iov.iov_len = sizeof (struct req_lib_confdb_key_create_typed);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (
confdb_inst->c,
&iov,
1,
&res,
sizeof (res));
sizeof (res), -1));
if (error != CS_OK) {
goto error_exit;
@ -857,7 +853,7 @@ cs_error_t confdb_key_delete (
struct confdb_inst *confdb_inst;
struct iovec iov;
struct req_lib_confdb_key_delete req_lib_confdb_key_delete;
coroipc_response_header_t res;
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) {
@ -885,12 +881,12 @@ cs_error_t confdb_key_delete (
iov.iov_base = (char *)&req_lib_confdb_key_delete;
iov.iov_len = sizeof (struct req_lib_confdb_key_delete);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (
confdb_inst->c,
&iov,
1,
&res,
sizeof (res));
sizeof (res), -1));
if (error != CS_OK) {
goto error_exit;
@ -942,12 +938,12 @@ cs_error_t confdb_key_get (
iov.iov_base = (char *)&req_lib_confdb_key_get;
iov.iov_len = sizeof (struct req_lib_confdb_key_get);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
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));
sizeof (struct res_lib_confdb_key_get), -1));
if (error != CS_OK) {
goto error_exit;
@ -1003,12 +999,12 @@ cs_error_t confdb_key_get_typed (
iov.iov_base = (char *)&req_lib_confdb_key_get;
iov.iov_len = sizeof (struct req_lib_confdb_key_get);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (
confdb_inst->c,
&iov,
1,
&response,
sizeof (struct res_lib_confdb_key_get_typed));
sizeof (struct res_lib_confdb_key_get_typed), -1));
if (error != CS_OK) {
goto error_exit;
@ -1065,12 +1061,12 @@ cs_error_t confdb_key_increment (
iov.iov_base = (char *)&req_lib_confdb_key_get;
iov.iov_len = sizeof (struct req_lib_confdb_key_get);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
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));
sizeof (struct res_lib_confdb_key_incdec), -1));
if (error != CS_OK) {
goto error_exit;
@ -1124,12 +1120,12 @@ cs_error_t confdb_key_decrement (
iov.iov_base = (char *)&req_lib_confdb_key_get;
iov.iov_len = sizeof (struct req_lib_confdb_key_get);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
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));
sizeof (struct res_lib_confdb_key_incdec), -1));
if (error != CS_OK) {
goto error_exit;
@ -1160,7 +1156,7 @@ cs_error_t confdb_key_replace (
struct confdb_inst *confdb_inst;
struct iovec iov;
struct req_lib_confdb_key_replace req_lib_confdb_key_replace;
coroipc_response_header_t res;
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) {
@ -1190,12 +1186,12 @@ cs_error_t confdb_key_replace (
iov.iov_base = (char *)&req_lib_confdb_key_replace;
iov.iov_len = sizeof (struct req_lib_confdb_key_replace);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (
confdb_inst->c,
&iov,
1,
&res,
sizeof (res));
sizeof (res), -1));
if (error != CS_OK) {
goto error_exit;
@ -1362,12 +1358,12 @@ cs_error_t confdb_object_find (
iov.iov_base = (char *)&req_lib_confdb_object_find;
iov.iov_len = sizeof (struct req_lib_confdb_object_find);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
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));
sizeof (struct res_lib_confdb_object_find), -1));
if (error != CS_OK) {
goto error_exit;
@ -1431,12 +1427,12 @@ cs_error_t confdb_object_iter (
iov.iov_base = (char *)&req_lib_confdb_object_iter;
iov.iov_len = sizeof (struct req_lib_confdb_object_iter);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
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));
sizeof (struct res_lib_confdb_object_iter), -1));
if (error != CS_OK) {
goto error_exit;
@ -1503,12 +1499,12 @@ cs_error_t confdb_key_iter (
iov.iov_base = (char *)&req_lib_confdb_key_iter;
iov.iov_len = sizeof (struct req_lib_confdb_key_iter);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
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));
sizeof (struct res_lib_confdb_key_iter), -1));
if (error != CS_OK) {
goto error_exit;
@ -1579,12 +1575,12 @@ cs_error_t confdb_key_iter_typed (
iov.iov_base = (char *)&req_lib_confdb_key_iter;
iov.iov_len = sizeof (struct req_lib_confdb_key_iter);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (
confdb_inst->c,
&iov,
1,
&response,
sizeof (struct res_lib_confdb_key_iter_typed));
sizeof (struct res_lib_confdb_key_iter_typed), -1));
if (error != CS_OK) {
goto error_exit;
@ -1616,7 +1612,7 @@ cs_error_t confdb_write (
cs_error_t error;
struct confdb_inst *confdb_inst;
struct iovec iov;
coroipc_request_header_t req;
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));
@ -1633,18 +1629,18 @@ cs_error_t confdb_write (
goto error_exit;
}
req.size = sizeof (coroipc_request_header_t);
req.size = sizeof (struct qb_ipc_request_header);
req.id = MESSAGE_REQ_CONFDB_WRITE;
iov.iov_base = (char *)&req;
iov.iov_len = sizeof (coroipc_request_header_t);
iov.iov_len = sizeof (struct qb_ipc_request_header);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (
confdb_inst->c,
&iov,
1,
&res_lib_confdb_write,
sizeof (struct res_lib_confdb_write));
sizeof (struct res_lib_confdb_write), -1));
if (error != CS_OK) {
/* FIXME: set error_text */
@ -1654,7 +1650,7 @@ cs_error_t confdb_write (
error = res_lib_confdb_write.header.error;
if (res_lib_confdb_write.error.length) {
memcpy(error_text, res_lib_confdb_write.error.value,
MIN(res_lib_confdb_write.error.length,errbuf_len));
QB_MIN(res_lib_confdb_write.error.length,errbuf_len));
error_text[errbuf_len-1] = '\0';
}
@ -1697,12 +1693,12 @@ cs_error_t confdb_reload (
iov.iov_base = (char *)&req_lib_confdb_reload;
iov.iov_len = sizeof (req_lib_confdb_reload);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (
confdb_inst->c,
&iov,
1,
&res_lib_confdb_reload,
sizeof (struct res_lib_confdb_reload));
sizeof (struct res_lib_confdb_reload), -1));
if (error != CS_OK) {
/* FIXME: set error_text */
@ -1712,7 +1708,7 @@ cs_error_t confdb_reload (
error = res_lib_confdb_reload.header.error;
if(res_lib_confdb_reload.error.length) {
memcpy(error_text, res_lib_confdb_reload.error.value,
MIN(res_lib_confdb_reload.error.length,errbuf_len));
QB_MIN(res_lib_confdb_reload.error.length,errbuf_len));
error_text[errbuf_len-1] = '\0';
}
@ -1731,7 +1727,7 @@ cs_error_t confdb_track_changes (
struct confdb_inst *confdb_inst;
struct iovec iov;
struct req_lib_confdb_object_track_start req;
coroipc_response_header_t res;
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) {
@ -1751,12 +1747,12 @@ cs_error_t confdb_track_changes (
iov.iov_base = (char *)&req;
iov.iov_len = sizeof (struct req_lib_confdb_object_track_start);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (
confdb_inst->c,
&iov,
1,
&res,
sizeof (coroipc_response_header_t));
sizeof (struct qb_ipc_response_header), -1));
if (error != CS_OK) {
goto error_exit;
@ -1775,8 +1771,8 @@ cs_error_t confdb_stop_track_changes (confdb_handle_t handle)
cs_error_t error;
struct confdb_inst *confdb_inst;
struct iovec iov;
coroipc_request_header_t req;
coroipc_response_header_t res;
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) {
@ -1788,18 +1784,18 @@ cs_error_t confdb_stop_track_changes (confdb_handle_t handle)
goto error_exit;
}
req.size = sizeof (coroipc_request_header_t);
req.size = sizeof (struct qb_ipc_request_header);
req.id = MESSAGE_REQ_CONFDB_TRACK_STOP;
iov.iov_base = (char *)&req;
iov.iov_len = sizeof (coroipc_request_header_t);
iov.iov_len = sizeof (struct qb_ipc_request_header);
error = coroipcc_msg_send_reply_receive (
confdb_inst->handle,
error = qb_to_cs_error (qb_ipcc_sendv_recv (
confdb_inst->c,
&iov,
1,
&res,
sizeof (coroipc_response_header_t));
sizeof (struct qb_ipc_response_header), -1));
if (error != CS_OK) {
goto error_exit;
@ -1813,6 +1809,3 @@ error_exit:
return (error);
}
/**
* @}
*/

File diff suppressed because it is too large Load Diff

288
lib/cpg.c
View File

@ -41,26 +41,29 @@
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/mman.h>
#include <errno.h>
#include <limits.h>
#include <qb/qbdefs.h>
#include <qb/qbipcc.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <corosync/coroipcc.h>
#include <corosync/corodefs.h>
#include <corosync/hdb.h>
#include <corosync/list.h>
#include <corosync/corotypes.h>
#include <corosync/corodefs.h>
#include <corosync/cpg.h>
#include <corosync/ipc_cpg.h>
#include "util.h"
struct cpg_inst {
hdb_handle_t handle;
qb_ipcc_connection_t *c;
int finalize;
void *context;
union {
@ -74,7 +77,7 @@ DECLARE_HDB_DATABASE(cpg_handle_t_db,NULL);
struct cpg_iteration_instance_t {
cpg_iteration_handle_t cpg_iteration_handle;
hdb_handle_t conn_handle;
qb_ipcc_connection_t *conn;
hdb_handle_t executive_iteration_handle;
struct list_head list;
};
@ -86,6 +89,17 @@ DECLARE_HDB_DATABASE(cpg_iteration_handle_t_db,NULL);
* Internal (not visible by API) functions
*/
static cs_error_t
coroipcc_msg_send_reply_receive (
qb_ipcc_connection_t *c,
const struct iovec *iov,
unsigned int iov_len,
void *res_msg,
size_t res_len)
{
return qb_to_cs_error(qb_ipcc_sendv_recv(c, iov, iov_len, res_msg, res_len, -1));
}
static void cpg_iteration_instance_finalize (struct cpg_iteration_instance_t *cpg_iteration_instance)
{
list_del (&cpg_iteration_instance->list);
@ -157,14 +171,9 @@ cs_error_t cpg_model_initialize (
goto error_destroy;
}
error = coroipcc_service_connect (
COROSYNC_SOCKET_NAME,
CPG_SERVICE,
IPC_REQUEST_SIZE,
IPC_RESPONSE_SIZE,
IPC_DISPATCH_SIZE,
&cpg_inst->handle);
if (error != CS_OK) {
cpg_inst->c = qb_ipcc_connect ("cpg", IPC_REQUEST_SIZE);
if (cpg_inst->c == NULL) {
error = qb_to_cs_error(-errno);
goto error_put_destroy;
}
@ -235,13 +244,13 @@ cs_error_t cpg_finalize (
iov.iov_base = (void *)&req_lib_cpg_finalize;
iov.iov_len = sizeof (struct req_lib_cpg_finalize);
error = coroipcc_msg_send_reply_receive (cpg_inst->handle,
error = coroipcc_msg_send_reply_receive (cpg_inst->c,
&iov,
1,
&res_lib_cpg_finalize,
sizeof (struct res_lib_cpg_finalize));
coroipcc_service_disconnect (cpg_inst->handle);
qb_ipcc_disconnect(cpg_inst->c);
cpg_inst_finalize (cpg_inst, handle);
hdb_handle_put (&cpg_handle_t_db, handle);
@ -261,7 +270,7 @@ cs_error_t cpg_fd_get (
return (error);
}
error = coroipcc_fd_get (cpg_inst->handle, fd);
error = qb_to_cs_error (qb_ipcc_fd_get (cpg_inst->c, fd));
hdb_handle_put (&cpg_handle_t_db, handle);
@ -318,7 +327,7 @@ cs_error_t cpg_dispatch (
struct res_lib_cpg_deliver_callback *res_cpg_deliver_callback;
struct res_lib_cpg_totem_confchg_callback *res_cpg_totem_confchg_callback;
struct cpg_inst cpg_inst_copy;
coroipc_response_header_t *dispatch_data;
struct qb_ipc_response_header *dispatch_data;
struct cpg_address member_list[CPG_MEMBERS_MAX];
struct cpg_address left_list[CPG_MEMBERS_MAX];
struct cpg_address joined_list[CPG_MEMBERS_MAX];
@ -328,6 +337,8 @@ cs_error_t cpg_dispatch (
unsigned int i;
struct cpg_ring_id ring_id;
uint32_t totem_member_list[CPG_MEMBERS_MAX];
int32_t errno_res;
char dispatch_buf[IPC_DISPATCH_SIZE];
error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
if (error != CS_OK) {
@ -342,11 +353,14 @@ cs_error_t cpg_dispatch (
timeout = 0;
}
dispatch_data = (struct qb_ipc_response_header *)dispatch_buf;
do {
error = coroipcc_dispatch_get (
cpg_inst->handle,
(void **)&dispatch_data,
errno_res = qb_ipcc_event_recv (
cpg_inst->c,
dispatch_buf,
IPC_DISPATCH_SIZE,
timeout);
error = qb_to_cs_error (errno_res);
if (error == CS_ERR_BAD_HANDLE) {
error = CS_OK;
goto error_put;
@ -369,7 +383,6 @@ cs_error_t cpg_dispatch (
* operate at the same time that cpgFinalize has been called.
*/
memcpy (&cpg_inst_copy, cpg_inst, sizeof (struct cpg_inst));
switch (cpg_inst_copy.model_data.model) {
case CPG_MODEL_V1:
/*
@ -451,14 +464,12 @@ cs_error_t cpg_dispatch (
totem_member_list);
break;
default:
coroipcc_dispatch_put (cpg_inst->handle);
error = CS_ERR_LIBRARY;
goto error_put;
break;
} /* - switch (dispatch_data->id) */
break; /* case CPG_MODEL_V1 */
} /* - switch (cpg_inst_copy.model_data.model) */
coroipcc_dispatch_put (cpg_inst->handle);
/*
* Determine if more messages should be processed
@ -481,7 +492,7 @@ cs_error_t cpg_join (
struct cpg_inst *cpg_inst;
struct iovec iov[2];
struct req_lib_cpg_join req_lib_cpg_join;
struct res_lib_cpg_join res_lib_cpg_join;
struct res_lib_cpg_join response;
error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
if (error != CS_OK) {
@ -507,15 +518,15 @@ cs_error_t cpg_join (
iov[0].iov_len = sizeof (struct req_lib_cpg_join);
do {
error = coroipcc_msg_send_reply_receive (cpg_inst->handle, iov, 1,
&res_lib_cpg_join, sizeof (struct res_lib_cpg_join));
error = coroipcc_msg_send_reply_receive (cpg_inst->c, iov, 1,
&response, sizeof (struct res_lib_cpg_join));
if (error != CS_OK) {
goto error_exit;
}
} while (res_lib_cpg_join.header.error == CPG_ERR_BUSY);
} while (response.header.error == CPG_ERR_BUSY);
error = res_lib_cpg_join.header.error;
error = response.header.error;
error_exit:
hdb_handle_put (&cpg_handle_t_db, handle);
@ -548,7 +559,7 @@ cs_error_t cpg_leave (
iov[0].iov_len = sizeof (struct req_lib_cpg_leave);
do {
error = coroipcc_msg_send_reply_receive (cpg_inst->handle, iov, 1,
error = coroipcc_msg_send_reply_receive (cpg_inst->c, iov, 1,
&res_lib_cpg_leave, sizeof (struct res_lib_cpg_leave));
if (error != CS_OK) {
@ -596,14 +607,14 @@ cs_error_t cpg_membership_get (
sizeof (struct cpg_name));
iov.iov_base = (void *)&req_lib_cpg_membership_get;
iov.iov_len = sizeof (coroipc_request_header_t);
iov.iov_len = sizeof (struct qb_ipc_request_header);
do {
error = coroipcc_msg_send_reply_receive (cpg_inst->handle, &iov, 1,
&res_lib_cpg_membership_get, sizeof (res_lib_cpg_membership_get));
error = coroipcc_msg_send_reply_receive (cpg_inst->c, &iov, 1,
&res_lib_cpg_membership_get, sizeof (res_lib_cpg_membership_get));
if (error != CS_OK) {
goto error_exit;
if (error != CS_OK) {
goto error_exit;
}
} while (res_lib_cpg_membership_get.header.error == CPG_ERR_BUSY);
@ -641,13 +652,13 @@ cs_error_t cpg_local_get (
return (error);
}
req_lib_cpg_local_get.header.size = sizeof (coroipc_request_header_t);
req_lib_cpg_local_get.header.size = sizeof (struct qb_ipc_request_header);
req_lib_cpg_local_get.header.id = MESSAGE_REQ_CPG_LOCAL_GET;
iov.iov_base = (void *)&req_lib_cpg_local_get;
iov.iov_len = sizeof (struct req_lib_cpg_local_get);
error = coroipcc_msg_send_reply_receive (cpg_inst->handle, &iov, 1,
error = coroipcc_msg_send_reply_receive (cpg_inst->c, &iov, 1,
&res_lib_cpg_local_get, sizeof (res_lib_cpg_local_get));
if (error != CS_OK) {
@ -675,19 +686,103 @@ cs_error_t cpg_flow_control_state_get (
if (error != CS_OK) {
return (error);
}
error = coroipcc_dispatch_flow_control_get (cpg_inst->handle, (unsigned int *)flow_control_state);
*flow_control_state = CPG_FLOW_CONTROL_DISABLED;
error = CS_OK;
hdb_handle_put (&cpg_handle_t_db, handle);
return (error);
}
static int
memory_map (char *path, const char *file, void **buf, size_t bytes)
{
int32_t fd;
void *addr_orig;
void *addr;
int32_t res;
char *buffer;
int32_t i;
int32_t written;
long page_size;
snprintf (path, PATH_MAX, "/dev/shm/%s", file);
fd = mkstemp (path);
if (fd == -1) {
snprintf (path, PATH_MAX, LOCALSTATEDIR "/run/%s", file);
fd = mkstemp (path);
if (fd == -1) {
return (-1);
}
}
res = ftruncate (fd, bytes);
if (res == -1) {
goto error_close_unlink;
}
page_size = sysconf(_SC_PAGESIZE);
buffer = malloc (page_size);
if (buffer == NULL) {
goto error_close_unlink;
}
memset (buffer, 0, page_size);
for (i = 0; i < (bytes / page_size); i++) {
retry_write:
written = write (fd, buffer, page_size);
if (written == -1 && errno == EINTR) {
goto retry_write;
}
if (written != page_size) {
free (buffer);
goto error_close_unlink;
}
}
free (buffer);
addr_orig = mmap (NULL, bytes, PROT_NONE,
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
if (addr_orig == MAP_FAILED) {
goto error_close_unlink;
}
addr = mmap (addr_orig, bytes, PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_SHARED, fd, 0);
if (addr != addr_orig) {
goto error_close_unlink;
}
#ifdef COROSYNC_BSD
madvise(addr_orig, bytes, MADV_NOSYNC);
#endif
res = close (fd);
if (res) {
return (-1);
}
*buf = addr_orig;
return 0;
error_close_unlink:
close (fd);
unlink(path);
return -1;
}
cs_error_t cpg_zcb_alloc (
cpg_handle_t handle,
size_t size,
void **buffer)
{
void *buf = NULL;
char path[128];
mar_req_coroipcc_zc_alloc_t req_coroipcc_zc_alloc;
struct qb_ipc_response_header res_coroipcs_zc_alloc;
size_t map_size;
struct iovec iovec;
struct coroipcs_zc_header *hdr;
cs_error_t error;
struct cpg_inst *cpg_inst;
@ -696,10 +791,27 @@ cs_error_t cpg_zcb_alloc (
return (error);
}
error = coroipcc_zcb_alloc (cpg_inst->handle,
buffer,
size,
sizeof (struct req_lib_cpg_mcast));
map_size = size + sizeof (struct req_lib_cpg_mcast) + sizeof (struct coroipcs_zc_header);
assert(memory_map (path, "corosync_zerocopy-XXXXXX", &buf, map_size) != -1);
req_coroipcc_zc_alloc.header.size = sizeof (mar_req_coroipcc_zc_alloc_t);
req_coroipcc_zc_alloc.header.id = MESSAGE_REQ_CPG_ZC_ALLOC;
req_coroipcc_zc_alloc.map_size = map_size;
strcpy (req_coroipcc_zc_alloc.path_to_file, path);
iovec.iov_base = (void *)&req_coroipcc_zc_alloc;
iovec.iov_len = sizeof (mar_req_coroipcc_zc_alloc_t);
error = coroipcc_msg_send_reply_receive (
cpg_inst->c,
&iovec,
1,
&res_coroipcs_zc_alloc,
sizeof (struct qb_ipc_response_header));
hdr = (struct coroipcs_zc_header *)buf;
hdr->map_size = map_size;
*buffer = ((char *)buf) + sizeof (struct coroipcs_zc_header);
hdb_handle_put (&cpg_handle_t_db, handle);
*buffer = ((char *)*buffer) + sizeof (struct req_lib_cpg_mcast);
@ -713,13 +825,32 @@ cs_error_t cpg_zcb_free (
{
cs_error_t error;
struct cpg_inst *cpg_inst;
mar_req_coroipcc_zc_free_t req_coroipcc_zc_free;
struct qb_ipc_response_header res_coroipcs_zc_free;
struct iovec iovec;
struct coroipcs_zc_header *header = (struct coroipcs_zc_header *)((char *)buffer - sizeof (struct coroipcs_zc_header));
error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
if (error != CS_OK) {
return (error);
}
coroipcc_zcb_free (cpg_inst->handle, ((char *)buffer) - sizeof (struct req_lib_cpg_mcast));
req_coroipcc_zc_free.header.size = sizeof (mar_req_coroipcc_zc_free_t);
req_coroipcc_zc_free.header.id = MESSAGE_REQ_CPG_ZC_FREE;
req_coroipcc_zc_free.map_size = header->map_size;
req_coroipcc_zc_free.server_address = header->server_address;
iovec.iov_base = (void *)&req_coroipcc_zc_free;
iovec.iov_len = sizeof (mar_req_coroipcc_zc_free_t);
error = coroipcc_msg_send_reply_receive (
cpg_inst->c,
&iovec,
1,
&res_coroipcs_zc_free,
sizeof (struct qb_ipc_response_header));
munmap ((void *)header, header->map_size);
hdb_handle_put (&cpg_handle_t_db, handle);
@ -736,12 +867,14 @@ cs_error_t cpg_zcb_mcast_joined (
struct cpg_inst *cpg_inst;
struct req_lib_cpg_mcast *req_lib_cpg_mcast;
struct res_lib_cpg_mcast res_lib_cpg_mcast;
mar_req_coroipcc_zc_execute_t req_coroipcc_zc_execute;
struct coroipcs_zc_header *hdr;
struct iovec iovec;
error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
if (error != CS_OK) {
return (error);
}
req_lib_cpg_mcast = (struct req_lib_cpg_mcast *)(((char *)msg) - sizeof (struct req_lib_cpg_mcast));
req_lib_cpg_mcast->header.size = sizeof (struct req_lib_cpg_mcast) +
msg_len;
@ -750,11 +883,21 @@ cs_error_t cpg_zcb_mcast_joined (
req_lib_cpg_mcast->guarantee = guarantee;
req_lib_cpg_mcast->msglen = msg_len;
error = coroipcc_zcb_msg_send_reply_receive (
cpg_inst->handle,
req_lib_cpg_mcast,
hdr = (struct coroipcs_zc_header *)(((char *)req_lib_cpg_mcast) - sizeof (struct coroipcs_zc_header));
req_coroipcc_zc_execute.header.size = sizeof (mar_req_coroipcc_zc_execute_t);
req_coroipcc_zc_execute.header.id = MESSAGE_REQ_CPG_ZC_EXECUTE;
req_coroipcc_zc_execute.server_address = hdr->server_address;
iovec.iov_base = (void *)&req_coroipcc_zc_execute;
iovec.iov_len = sizeof (mar_req_coroipcc_zc_execute_t);
error = coroipcc_msg_send_reply_receive (
cpg_inst->c,
&iovec,
1,
&res_lib_cpg_mcast,
sizeof (res_lib_cpg_mcast));
sizeof(res_lib_cpg_mcast));
if (error != CS_OK) {
goto error_exit;
@ -779,7 +922,6 @@ cs_error_t cpg_mcast_joined (
struct cpg_inst *cpg_inst;
struct iovec iov[64];
struct req_lib_cpg_mcast req_lib_cpg_mcast;
struct res_lib_cpg_mcast res_lib_cpg_mcast;
size_t msg_len = 0;
error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
@ -802,16 +944,8 @@ cs_error_t cpg_mcast_joined (
iov[0].iov_len = sizeof (struct req_lib_cpg_mcast);
memcpy (&iov[1], iovec, iov_len * sizeof (struct iovec));
error = coroipcc_msg_send_reply_receive (cpg_inst->handle, iov,
iov_len + 1, &res_lib_cpg_mcast, sizeof (res_lib_cpg_mcast));
error = qb_to_cs_error(qb_ipcc_sendv(cpg_inst->c, iov, iov_len + 1));
if (error != CS_OK) {
goto error_exit;
}
error = res_lib_cpg_mcast.header.error;
error_exit:
hdb_handle_put (&cpg_handle_t_db, handle);
return (error);
@ -862,7 +996,7 @@ cs_error_t cpg_iteration_initialize(
goto error_destroy;
}
cpg_iteration_instance->conn_handle = cpg_inst->handle;
cpg_iteration_instance->conn = cpg_inst->c;
list_init (&cpg_iteration_instance->list);
@ -876,7 +1010,7 @@ cs_error_t cpg_iteration_initialize(
iov.iov_base = (void *)&req_lib_cpg_iterationinitialize;
iov.iov_len = sizeof (struct req_lib_cpg_iterationinitialize);
error = coroipcc_msg_send_reply_receive (cpg_inst->handle,
error = coroipcc_msg_send_reply_receive (cpg_inst->c,
&iov,
1,
&res_lib_cpg_iterationinitialize,
@ -914,9 +1048,7 @@ cs_error_t cpg_iteration_next(
cs_error_t error;
struct cpg_iteration_instance_t *cpg_iteration_instance;
struct req_lib_cpg_iterationnext req_lib_cpg_iterationnext;
struct res_lib_cpg_iterationnext *res_lib_cpg_iterationnext;
struct iovec iov;
void *return_address;
struct res_lib_cpg_iterationnext res_lib_cpg_iterationnext;
if (description == NULL) {
return CS_ERR_INVALID_PARAM;
@ -932,27 +1064,25 @@ cs_error_t cpg_iteration_next(
req_lib_cpg_iterationnext.header.id = MESSAGE_REQ_CPG_ITERATIONNEXT;
req_lib_cpg_iterationnext.iteration_handle = cpg_iteration_instance->executive_iteration_handle;
iov.iov_base = (void *)&req_lib_cpg_iterationnext;
iov.iov_len = sizeof (struct req_lib_cpg_iterationnext);
error = coroipcc_msg_send_reply_receive_in_buf_get (cpg_iteration_instance->conn_handle,
&iov,
1,
&return_address);
res_lib_cpg_iterationnext = return_address;
error = qb_to_cs_error (qb_ipcc_send (cpg_iteration_instance->conn,
&req_lib_cpg_iterationnext,
req_lib_cpg_iterationnext.header.size));
if (error != CS_OK) {
goto error_put;
}
error = qb_to_cs_error (qb_ipcc_recv (cpg_iteration_instance->conn,
&res_lib_cpg_iterationnext,
sizeof(struct res_lib_cpg_iterationnext), -1));
if (error != CS_OK) {
goto error_put;
}
marshall_from_mar_cpg_iteration_description_t(
description,
&res_lib_cpg_iterationnext->description);
&res_lib_cpg_iterationnext.description);
error = res_lib_cpg_iterationnext->header.error;
coroipcc_msg_send_reply_receive_in_buf_put(
cpg_iteration_instance->conn_handle);
error = res_lib_cpg_iterationnext.header.error;
error_put:
hdb_handle_put (&cpg_iteration_handle_t_db, handle);
@ -983,7 +1113,7 @@ cs_error_t cpg_iteration_finalize (
iov.iov_base = (void *)&req_lib_cpg_iterationfinalize;
iov.iov_len = sizeof (struct req_lib_cpg_iterationfinalize);
error = coroipcc_msg_send_reply_receive (cpg_iteration_instance->conn_handle,
error = coroipcc_msg_send_reply_receive (cpg_iteration_instance->conn,
&iov,
1,
&res_lib_cpg_iterationfinalize,

View File

@ -47,10 +47,9 @@
#include <sys/socket.h>
#include <errno.h>
#include <qb/qbipcc.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <corosync/coroipcc.h>
#include <corosync/corodefs.h>
#include <corosync/hdb.h>
@ -59,11 +58,8 @@
#include "util.h"
#undef MIN
#define MIN(x,y) ((x) < (y) ? (x) : (y))
struct evs_inst {
hdb_handle_t handle;
qb_ipcc_connection_t *c;
int finalize;
evs_callbacks_t callbacks;
void *context;
@ -105,13 +101,11 @@ evs_error_t evs_initialize (
goto error_destroy;
}
error = coroipcc_service_connect (
COROSYNC_SOCKET_NAME,
EVS_SERVICE,
IPC_REQUEST_SIZE,
IPC_RESPONSE_SIZE,
IPC_DISPATCH_SIZE,
&evs_inst->handle);
evs_inst->c = qb_ipcc_connect ("evs", IPC_REQUEST_SIZE);
if (evs_inst->c == NULL) {
error = qb_to_cs_error(-errno);
goto error_put_destroy;
}
if (error != EVS_OK) {
goto error_put_destroy;
}
@ -153,7 +147,7 @@ evs_error_t evs_finalize (
evs_inst->finalize = 1;
coroipcc_service_disconnect (evs_inst->handle);
qb_ipcc_disconnect (evs_inst->c);
hdb_handle_destroy (&evs_handle_t_db, handle);
@ -174,7 +168,7 @@ evs_error_t evs_fd_get (
return (error);
}
coroipcc_fd_get (evs_inst->handle, fd);
qb_ipcc_fd_get (evs_inst->c, fd);
hdb_handle_put (&evs_handle_t_db, handle);
@ -230,7 +224,8 @@ evs_error_t evs_dispatch (
struct res_evs_confchg_callback *res_evs_confchg_callback;
struct res_evs_deliver_callback *res_evs_deliver_callback;
evs_callbacks_t callbacks;
coroipc_response_header_t *dispatch_data;
struct qb_ipc_response_header *dispatch_data;
char dispatch_buf[IPC_DISPATCH_SIZE];
error = hdb_error_to_cs(hdb_handle_get (&evs_handle_t_db, handle, (void *)&evs_inst));
if (error != CS_OK) {
@ -245,11 +240,13 @@ evs_error_t evs_dispatch (
timeout = 0;
}
dispatch_data = (struct qb_ipc_response_header *)dispatch_buf;
do {
error = coroipcc_dispatch_get (
evs_inst->handle,
(void **)&dispatch_data,
timeout);
error = qb_to_cs_error(qb_ipcc_event_recv (
evs_inst->c,
dispatch_buf,
IPC_DISPATCH_SIZE,
timeout));
if (error == CS_ERR_BAD_HANDLE) {
error = CS_OK;
goto error_put;
@ -308,12 +305,10 @@ evs_error_t evs_dispatch (
break;
default:
coroipcc_dispatch_put (evs_inst->handle);
error = CS_ERR_LIBRARY;
goto error_put;
break;
}
coroipcc_dispatch_put (evs_inst->handle);
/*
* Determine if more messages should be processed
@ -354,8 +349,8 @@ evs_error_t evs_join (
iov[1].iov_base = (void*) groups; /* cast away const */
iov[1].iov_len = (group_entries * sizeof (struct evs_group));
error = coroipcc_msg_send_reply_receive (evs_inst->handle, iov, 2,
&res_lib_evs_join, sizeof (struct res_lib_evs_join));
error = qb_to_cs_error(qb_ipcc_sendv_recv (evs_inst->c, iov, 2,
&res_lib_evs_join, sizeof (struct res_lib_evs_join), -1));
if (error != CS_OK) {
goto error_exit;
@ -395,8 +390,8 @@ evs_error_t evs_leave (
iov[1].iov_base = (void *) groups; /* cast away const */
iov[1].iov_len = (group_entries * sizeof (struct evs_group));
error = coroipcc_msg_send_reply_receive (evs_inst->handle, iov, 2,
&res_lib_evs_leave, sizeof (struct res_lib_evs_leave));
error = qb_to_cs_error(qb_ipcc_sendv_recv (evs_inst->c, iov, 2,
&res_lib_evs_leave, sizeof (struct res_lib_evs_leave), -1));
if (error != CS_OK) {
goto error_exit;
@ -444,10 +439,10 @@ evs_error_t evs_mcast_joined (
iov[0].iov_len = sizeof (struct req_lib_evs_mcast_joined);
memcpy (&iov[1], iovec, iov_len * sizeof (struct iovec));
error = coroipcc_msg_send_reply_receive (evs_inst->handle, iov,
error = qb_to_cs_error(qb_ipcc_sendv_recv (evs_inst->c, iov,
iov_len + 1,
&res_lib_evs_mcast_joined,
sizeof (struct res_lib_evs_mcast_joined));
sizeof (struct res_lib_evs_mcast_joined), -1));
if (error != CS_OK) {
goto error_exit;
@ -497,10 +492,10 @@ evs_error_t evs_mcast_groups (
iov[1].iov_len = (group_entries * sizeof (struct evs_group));
memcpy (&iov[2], iovec, iov_len * sizeof (struct iovec));
error = coroipcc_msg_send_reply_receive (evs_inst->handle, iov,
error = qb_to_cs_error(qb_ipcc_sendv_recv (evs_inst->c, iov,
iov_len + 2,
&res_lib_evs_mcast_groups,
sizeof (struct res_lib_evs_mcast_groups));
sizeof (struct res_lib_evs_mcast_groups), -1));
if (error != CS_OK) {
goto error_exit;
@ -537,11 +532,11 @@ evs_error_t evs_membership_get (
iov.iov_base = (void *)&req_lib_evs_membership_get;
iov.iov_len = sizeof (struct req_lib_evs_membership_get);
error = coroipcc_msg_send_reply_receive (evs_inst->handle,
error = qb_to_cs_error(qb_ipcc_sendv_recv (evs_inst->c,
&iov,
1,
&res_lib_evs_membership_get,
sizeof (struct res_lib_evs_membership_get));
sizeof (struct res_lib_evs_membership_get), -1));
if (error != CS_OK) {
goto error_exit;
@ -555,7 +550,7 @@ evs_error_t evs_membership_get (
if (local_nodeid) {
*local_nodeid = res_lib_evs_membership_get.local_nodeid;
}
*member_list_entries = MIN (*member_list_entries,
*member_list_entries = QB_MIN (*member_list_entries,
res_lib_evs_membership_get.member_list_entries);
if (member_list) {
memcpy (member_list, &res_lib_evs_membership_get.member_list,

View File

@ -14,17 +14,4 @@ COROSYNC_CFG_0.82 {
corosync_cfg_ring_reenable;
corosync_cfg_service_load;
corosync_cfg_service_unload;
local:
coroipcc_service_connect;
coroipcc_service_disconnect;
coroipcc_dispatch_flow_control_get;
coroipcc_fd_get;
coroipcc_dispatch_recv;
coroipcc_msg_send_reply_receive;
coroipcc_msg_send_reply_receive_in_buf;
coroipcc_zcb_alloc;
coroipcc_zcb_free;
coroipcc_zcb_msg_send_reply_receive;
};

View File

@ -21,16 +21,4 @@ COROSYNC_CONFDB_1.0 {
confdb_object_iter;
confdb_key_iter_start;
confdb_key_iter;
local:
coroipcc_service_connect;
coroipcc_service_disconnect;
coroipcc_dispatch_flow_control_get;
coroipcc_fd_get;
coroipcc_dispatch_recv;
coroipcc_msg_send_reply_receive;
coroipcc_msg_send_reply_receive_in_buf;
coroipcc_zcb_alloc;
coroipcc_zcb_free;
coroipcc_zcb_msg_send_reply_receive;
};

View File

@ -1,15 +0,0 @@
# Version and symbol export for libcoroipcc.so
COROSYNC_COROIPCC_3.0 {
global:
coroipcc_service_connect;
coroipcc_service_disconnect;
coroipcc_dispatch_flow_control_get;
coroipcc_fd_get;
coroipcc_dispatch_recv;
coroipcc_msg_send_reply_receive;
coroipcc_msg_send_reply_receive_in_buf;
coroipcc_zcb_alloc;
coroipcc_zcb_free;
coroipcc_zcb_msg_send_reply_receive;
};

View File

@ -14,16 +14,4 @@ COROSYNC_CPG_1.0 {
cpg_context_set;
cpg_zcb_alloc;
cpg_zcb_free;
local:
coroipcc_service_connect;
coroipcc_service_disconnect;
coroipcc_dispatch_flow_control_get;
coroipcc_fd_get;
coroipcc_dispatch_recv;
coroipcc_msg_send_reply_receive;
coroipcc_msg_send_reply_receive_in_buf;
coroipcc_zcb_alloc;
coroipcc_zcb_free;
coroipcc_zcb_msg_send_reply_receive;
};

View File

@ -11,16 +11,4 @@ COROSYNC_EVS_2.0 {
evs_mcast_joined;
evs_mcast_groups;
evs_membership_get;
local:
coroipcc_service_connect;
coroipcc_service_disconnect;
coroipcc_dispatch_flow_control_get;
coroipcc_fd_get;
coroipcc_dispatch_recv;
coroipcc_msg_send_reply_receive;
coroipcc_msg_send_reply_receive_in_buf;
coroipcc_zcb_alloc;
coroipcc_zcb_free;
coroipcc_zcb_msg_send_reply_receive;
};

View File

@ -3,16 +3,4 @@
COROSYNC_PLOAD_1.0 {
global:
pload_start;
local:
coroipcc_service_connect;
coroipcc_service_disconnect;
coroipcc_dispatch_flow_control_get;
coroipcc_fd_get;
coroipcc_dispatch_recv;
coroipcc_msg_send_reply_receive;
coroipcc_msg_send_reply_receive_in_buf;
coroipcc_zcb_alloc;
coroipcc_zcb_free;
coroipcc_zcb_msg_send_reply_receive;
};

View File

@ -8,16 +8,4 @@ COROSYNC_QUORUM_1.0 {
quorum_initialize;
quorum_finalize;
quorum_dispatch;
local:
coroipcc_service_connect;
coroipcc_service_disconnect;
coroipcc_dispatch_flow_control_get;
coroipcc_fd_get;
coroipcc_dispatch_recv;
coroipcc_msg_send_reply_receive;
coroipcc_msg_send_reply_receive_in_buf;
coroipcc_zcb_alloc;
coroipcc_zcb_free;
coroipcc_zcb_msg_send_reply_receive;
};

View File

@ -17,16 +17,4 @@ COROSYNC_VOTEQUORUM_1.0 {
votequorum_trackstop;
votequorum_context_get;
votequorum_context_set;
local:
coroipcc_service_connect;
coroipcc_service_disconnect;
coroipcc_dispatch_flow_control_get;
coroipcc_fd_get;
coroipcc_dispatch_recv;
coroipcc_msg_send_reply_receive;
coroipcc_msg_send_reply_receive_in_buf;
coroipcc_zcb_alloc;
coroipcc_zcb_free;
coroipcc_zcb_msg_send_reply_receive;
};

View File

@ -41,9 +41,9 @@
#include <sys/socket.h>
#include <errno.h>
#include <qb/qbipcc.h>
#include <corosync/corotypes.h>
#include <corosync/coroipcc.h>
#include <corosync/coroipc_types.h>
#include <corosync/corodefs.h>
#include <corosync/hdb.h>
@ -53,7 +53,7 @@
#include "util.h"
struct pload_inst {
hdb_handle_t handle;
qb_ipcc_connection_t *c;
unsigned int finalize;
};
@ -88,14 +88,9 @@ unsigned int pload_initialize (
goto error_destroy;
}
error = coroipcc_service_connect (
COROSYNC_SOCKET_NAME,
PLOAD_SERVICE,
IPC_REQUEST_SIZE,
IPC_RESPONSE_SIZE,
IPC_DISPATCH_SIZE,
&pload_inst->handle);
if (error != CS_OK) {
pload_inst->c = qb_ipcc_connect ("pload", IPC_REQUEST_SIZE);
if (pload_inst->c == NULL) {
error = qb_to_cs_error(-errno);
goto error_put_destroy;
}
@ -132,7 +127,7 @@ unsigned int pload_finalize (
pload_inst->finalize = 1;
coroipcc_service_disconnect(pload_inst->handle);
qb_ipcc_disconnect(pload_inst->c);
(void)hdb_handle_destroy (&pload_handle_t_db, handle);
@ -153,7 +148,7 @@ unsigned int pload_fd_get (
return (error);
}
coroipcc_fd_get (pload_inst->handle, fd);
qb_ipcc_fd_get (pload_inst->c, fd);
(void)hdb_handle_put (&pload_handle_t_db, handle);
@ -186,11 +181,11 @@ unsigned int pload_start (
iov.iov_base = (char *)&req_lib_pload_start;
iov.iov_len = sizeof (struct req_lib_pload_start);
error = coroipcc_msg_send_reply_receive(pload_inst->handle,
error = qb_to_cs_error(qb_ipcc_sendv_recv(pload_inst->c,
&iov,
1,
&res_lib_pload_start,
sizeof (struct res_lib_pload_start));
sizeof (struct res_lib_pload_start), -1));
if (error != CS_OK) {
goto error_exit;

View File

@ -44,9 +44,8 @@
#include <sys/socket.h>
#include <errno.h>
#include <qb/qbipcc.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <corosync/coroipcc.h>
#include <corosync/corodefs.h>
#include <corosync/hdb.h>
@ -56,7 +55,7 @@
#include "util.h"
struct quorum_inst {
hdb_handle_t handle;
qb_ipcc_connection_t *c;
int finalize;
const void *context;
quorum_callbacks_t callbacks;
@ -81,14 +80,10 @@ cs_error_t quorum_initialize (
goto error_destroy;
}
error = coroipcc_service_connect (
COROSYNC_SOCKET_NAME,
QUORUM_SERVICE,
IPC_REQUEST_SIZE,
IPC_RESPONSE_SIZE,
IPC_DISPATCH_SIZE,
&quorum_inst->handle);
if (error != CS_OK) {
error = CS_OK;
quorum_inst->c = qb_ipcc_connect ("quorum", IPC_REQUEST_SIZE);
if (quorum_inst->c == NULL) {
error = qb_to_cs_error(-errno);
goto error_put_destroy;
}
@ -130,7 +125,7 @@ cs_error_t quorum_finalize (
quorum_inst->finalize = 1;
coroipcc_service_disconnect (quorum_inst->handle);
qb_ipcc_disconnect (quorum_inst->c);
(void)hdb_handle_destroy (&quorum_handle_t_db, handle);
@ -146,7 +141,7 @@ cs_error_t quorum_getquorate (
cs_error_t error;
struct quorum_inst *quorum_inst;
struct iovec iov;
coroipc_request_header_t req;
struct qb_ipc_request_header req;
struct res_lib_quorum_getquorate res_lib_quorum_getquorate;
error = hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (void *)&quorum_inst));
@ -160,12 +155,12 @@ cs_error_t quorum_getquorate (
iov.iov_base = (char *)&req;
iov.iov_len = sizeof (req);
error = coroipcc_msg_send_reply_receive (
quorum_inst->handle,
error = qb_to_cs_error(qb_ipcc_sendv_recv (
quorum_inst->c,
&iov,
1,
&res_lib_quorum_getquorate,
sizeof (struct res_lib_quorum_getquorate));
sizeof (struct res_lib_quorum_getquorate), -1));
if (error != CS_OK) {
goto error_exit;
@ -193,7 +188,7 @@ cs_error_t quorum_fd_get (
return (error);
}
error = coroipcc_fd_get (quorum_inst->handle, fd);
error = qb_to_cs_error(qb_ipcc_fd_get (quorum_inst->c, fd));
(void)hdb_handle_put (&quorum_handle_t_db, handle);
@ -248,7 +243,7 @@ cs_error_t quorum_trackstart (
struct quorum_inst *quorum_inst;
struct iovec iov;
struct req_lib_quorum_trackstart req_lib_quorum_trackstart;
coroipc_response_header_t res;
struct qb_ipc_response_header res;
error = hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (void *)&quorum_inst));
if (error != CS_OK) {
@ -262,12 +257,12 @@ cs_error_t quorum_trackstart (
iov.iov_base = (char *)&req_lib_quorum_trackstart;
iov.iov_len = sizeof (struct req_lib_quorum_trackstart);
error = coroipcc_msg_send_reply_receive (
quorum_inst->handle,
error = qb_to_cs_error(qb_ipcc_sendv_recv (
quorum_inst->c,
&iov,
1,
&res,
sizeof (res));
sizeof (res), -1));
if (error != CS_OK) {
goto error_exit;
@ -287,8 +282,8 @@ cs_error_t quorum_trackstop (
cs_error_t error;
struct quorum_inst *quorum_inst;
struct iovec iov;
coroipc_request_header_t req;
coroipc_response_header_t res;
struct qb_ipc_request_header req;
struct qb_ipc_response_header res;
error = hdb_error_to_cs(hdb_handle_get (&quorum_handle_t_db, handle, (void *)&quorum_inst));
if (error != CS_OK) {
@ -301,12 +296,12 @@ cs_error_t quorum_trackstop (
iov.iov_base = (char *)&req;
iov.iov_len = sizeof (req);
error = coroipcc_msg_send_reply_receive (
quorum_inst->handle,
error = qb_to_cs_error(qb_ipcc_sendv_recv (
quorum_inst->c,
&iov,
1,
&res,
sizeof (res));
sizeof (res), -1));
if (error != CS_OK) {
goto error_exit;
@ -329,7 +324,8 @@ cs_error_t quorum_dispatch (
int cont = 1; /* always continue do loop except when set to 0 */
struct quorum_inst *quorum_inst;
quorum_callbacks_t callbacks;
coroipc_response_header_t *dispatch_data;
struct qb_ipc_response_header *dispatch_data;
char dispatch_buf[IPC_DISPATCH_SIZE];
struct res_lib_quorum_notification *res_lib_quorum_notification;
if (dispatch_types != CS_DISPATCH_ONE &&
@ -353,11 +349,13 @@ cs_error_t quorum_dispatch (
timeout = 0;
}
dispatch_data = (struct qb_ipc_response_header *)dispatch_buf;
do {
error = coroipcc_dispatch_get (
quorum_inst->handle,
(void **)&dispatch_data,
timeout);
error = qb_to_cs_error (qb_ipcc_event_recv (
quorum_inst->c,
dispatch_buf,
IPC_DISPATCH_SIZE,
timeout));
if (error == CS_ERR_BAD_HANDLE) {
error = CS_OK;
goto error_put;
@ -399,12 +397,10 @@ cs_error_t quorum_dispatch (
break;
default:
coroipcc_dispatch_put (quorum_inst->handle);
error = CS_ERR_LIBRARY;
goto error_put;
break;
}
coroipcc_dispatch_put (quorum_inst->handle);
/*
* Determine if more messages should be processed

View File

@ -45,7 +45,7 @@
#include <errno.h>
#include <corosync/corotypes.h>
#include <corosync/coroipcc.h>
#include <qb/qbipcc.h>
#include <corosync/engine/objdb.h>
#include <corosync/engine/config.h>
#include <corosync/engine/logsys.h>

View File

@ -48,8 +48,7 @@
#include <errno.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <corosync/coroipcc.h>
#include <qb/qbipcc.h>
#include <corosync/corodefs.h>
#include <corosync/confdb.h>
#include <corosync/hdb.h>

View File

@ -36,28 +36,9 @@
#ifndef AIS_UTIL_H_DEFINED
#define AIS_UTIL_H_DEFINED
#include <errno.h>
#include <corosync/corotypes.h>
static inline cs_error_t hdb_error_to_cs (int res) \
{ \
if (res == 0) { \
return (CS_OK); \
} else { \
if (errno == EBADF) { \
return (CS_ERR_BAD_HANDLE); \
} else \
if (errno == ENOMEM) { \
return (CS_ERR_NO_MEMORY); \
} else \
if (errno == EMFILE) { \
return (CS_ERR_NO_RESOURCES); \
} else \
if (errno == EACCES) { \
return (CS_ERR_SECURITY); \
} \
return (CS_ERR_LIBRARY); \
} \
}
#define hdb_error_to_cs(_result_) qb_to_cs_error(-_result_)
#ifdef HAVE_SMALL_MEMORY_FOOTPRINT
#define IPC_REQUEST_SIZE 1024*64
@ -69,4 +50,103 @@ static inline cs_error_t hdb_error_to_cs (int res) \
#define IPC_DISPATCH_SIZE 8192*128
#endif /* HAVE_SMALL_MEMORY_FOOTPRINT */
static inline const char * cs_strerror(cs_error_t err)
{
switch (err) {
case CS_OK:
return "success";
case CS_ERR_LIBRARY:
return "CS_ERR_LIBRARY";
case CS_ERR_VERSION:
return "CS_ERR_VERSION";
case CS_ERR_INIT:
return "CS_ERR_INIT";
case CS_ERR_NO_MEMORY:
return "CS_ERR_NO_MEMORY";
case CS_ERR_NAME_TOO_LONG :
return "CS_ERR_NAME_TOO_LONG ";
case CS_ERR_TIMEOUT:
return "CS_ERR_TIMEOUT";
case CS_ERR_TRY_AGAIN:
return "CS_ERR_TRY_AGAIN";
case CS_ERR_INVALID_PARAM:
return "CS_ERR_INVALID_PARAM";
case CS_ERR_BAD_HANDLE:
return "CS_ERR_BAD_HANDLE";
case CS_ERR_BUSY :
return "CS_ERR_BUSY ";
case CS_ERR_ACCESS :
return "CS_ERR_ACCESS ";
case CS_ERR_NOT_EXIST :
return "CS_ERR_NOT_EXIST ";
case CS_ERR_EXIST :
return "CS_ERR_EXIST ";
case CS_ERR_NO_SPACE :
return "CS_ERR_NO_SPACE ";
case CS_ERR_INTERRUPT :
return "CS_ERR_INTERRUPT ";
case CS_ERR_NAME_NOT_FOUND :
return "CS_ERR_NAME_NOT_FOUND ";
case CS_ERR_NO_RESOURCES :
return "CS_ERR_NO_RESOURCES ";
case CS_ERR_NOT_SUPPORTED :
return "CS_ERR_NOT_SUPPORTED ";
case CS_ERR_BAD_OPERATION :
return "CS_ERR_BAD_OPERATION ";
case CS_ERR_FAILED_OPERATION :
return "CS_ERR_FAILED_OPERATION ";
case CS_ERR_MESSAGE_ERROR :
return "CS_ERR_MESSAGE_ERROR ";
case CS_ERR_QUEUE_FULL :
return "CS_ERR_QUEUE_FULL ";
case CS_ERR_QUEUE_NOT_AVAILABLE :
return "CS_ERR_QUEUE_NOT_AVAILABLE ";
case CS_ERR_BAD_FLAGS :
return "CS_ERR_BAD_FLAGS ";
case CS_ERR_TOO_BIG :
return "CS_ERR_TOO_BIG ";
case CS_ERR_NO_SECTIONS :
return "CS_ERR_NO_SECTIONS ";
case CS_ERR_CONTEXT_NOT_FOUND :
return "CS_ERR_CONTEXT_NOT_FOUND ";
case CS_ERR_TOO_MANY_GROUPS :
return "CS_ERR_TOO_MANY_GROUPS ";
case CS_ERR_SECURITY :
return "CS_ERR_SECURITY ";
default:
return "unknown error";
}
}
#endif /* AIS_UTIL_H_DEFINED */

View File

@ -45,10 +45,9 @@
#include <sys/socket.h>
#include <errno.h>
#include <qb/qbipcc.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <corosync/coroipcc.h>
#include <corosync/corodefs.h>
#include <corosync/hdb.h>
@ -58,7 +57,7 @@
#include "util.h"
struct votequorum_inst {
hdb_handle_t handle;
qb_ipcc_connection_t *c;
int finalize;
void *context;
votequorum_callbacks_t callbacks;
@ -83,13 +82,11 @@ cs_error_t votequorum_initialize (
goto error_destroy;
}
error = coroipcc_service_connect (
COROSYNC_SOCKET_NAME,
VOTEQUORUM_SERVICE,
IPC_REQUEST_SIZE,
IPC_RESPONSE_SIZE,
IPC_DISPATCH_SIZE,
&votequorum_inst->handle);
votequorum_inst->c = qb_ipcc_connect ("votequorum", IPC_REQUEST_SIZE);
if (votequorum_inst->c == NULL) {
error = qb_to_cs_error(-errno);
goto error_put_destroy;
}
if (error != CS_OK) {
goto error_put_destroy;
}
@ -132,7 +129,7 @@ cs_error_t votequorum_finalize (
votequorum_inst->finalize = 1;
coroipcc_service_disconnect (votequorum_inst->handle);
qb_ipcc_disconnect (votequorum_inst->c);
hdb_handle_destroy (&votequorum_handle_t_db, handle);
@ -165,12 +162,12 @@ cs_error_t votequorum_getinfo (
iov.iov_base = (char *)&req_lib_votequorum_getinfo;
iov.iov_len = sizeof (struct req_lib_votequorum_getinfo);
error = coroipcc_msg_send_reply_receive (
votequorum_inst->handle,
error = qb_to_cs_error(qb_ipcc_sendv_recv (
votequorum_inst->c,
&iov,
1,
&res_lib_votequorum_getinfo,
sizeof (struct res_lib_votequorum_getinfo));
sizeof (struct res_lib_votequorum_getinfo), -1));
if (error != CS_OK) {
goto error_exit;
@ -215,12 +212,12 @@ cs_error_t votequorum_setexpected (
iov.iov_base = (char *)&req_lib_votequorum_setexpected;
iov.iov_len = sizeof (struct req_lib_votequorum_setexpected);
error = coroipcc_msg_send_reply_receive (
votequorum_inst->handle,
error = qb_to_cs_error(qb_ipcc_sendv_recv (
votequorum_inst->c,
&iov,
1,
&res_lib_votequorum_status,
sizeof (struct res_lib_votequorum_status));
sizeof (struct res_lib_votequorum_status), -1));
if (error != CS_OK) {
goto error_exit;
@ -258,12 +255,12 @@ cs_error_t votequorum_setvotes (
iov.iov_base = (char *)&req_lib_votequorum_setvotes;
iov.iov_len = sizeof (struct req_lib_votequorum_setvotes);
error = coroipcc_msg_send_reply_receive (
votequorum_inst->handle,
error = qb_to_cs_error(qb_ipcc_sendv_recv (
votequorum_inst->c,
&iov,
1,
&res_lib_votequorum_status,
sizeof (struct res_lib_votequorum_status));
sizeof (struct res_lib_votequorum_status), -1));
if (error != CS_OK) {
goto error_exit;
@ -305,12 +302,12 @@ cs_error_t votequorum_qdisk_register (
iov.iov_base = (char *)&req_lib_votequorum_qdisk_register;
iov.iov_len = sizeof (struct req_lib_votequorum_qdisk_register);
error = coroipcc_msg_send_reply_receive (
votequorum_inst->handle,
error = qb_to_cs_error(qb_ipcc_sendv_recv (
votequorum_inst->c,
&iov,
1,
&res_lib_votequorum_status,
sizeof (struct res_lib_votequorum_status));
sizeof (struct res_lib_votequorum_status), -1));
if (error != CS_OK) {
goto error_exit;
@ -347,12 +344,12 @@ cs_error_t votequorum_qdisk_poll (
iov.iov_base = (char *)&req_lib_votequorum_qdisk_poll;
iov.iov_len = sizeof (struct req_lib_votequorum_qdisk_poll);
error = coroipcc_msg_send_reply_receive (
votequorum_inst->handle,
error = qb_to_cs_error(qb_ipcc_sendv_recv (
votequorum_inst->c,
&iov,
1,
&res_lib_votequorum_status,
sizeof (struct res_lib_votequorum_status));
sizeof (struct res_lib_votequorum_status), -1));
if (error != CS_OK) {
goto error_exit;
@ -386,12 +383,12 @@ cs_error_t votequorum_qdisk_unregister (
iov.iov_base = (char *)&req_lib_votequorum_general;
iov.iov_len = sizeof (struct req_lib_votequorum_general);
error = coroipcc_msg_send_reply_receive (
votequorum_inst->handle,
error = qb_to_cs_error(qb_ipcc_sendv_recv (
votequorum_inst->c,
&iov,
1,
&res_lib_votequorum_status,
sizeof (struct res_lib_votequorum_status));
sizeof (struct res_lib_votequorum_status), -1));
if (error != CS_OK) {
goto error_exit;
@ -429,12 +426,12 @@ cs_error_t votequorum_qdisk_getinfo (
iov.iov_base = (char *)&req_lib_votequorum_general;
iov.iov_len = sizeof (struct req_lib_votequorum_general);
error = coroipcc_msg_send_reply_receive (
votequorum_inst->handle,
error = qb_to_cs_error(qb_ipcc_sendv_recv (
votequorum_inst->c,
&iov,
1,
&res_lib_votequorum_qdisk_getinfo,
sizeof (struct res_lib_votequorum_qdisk_getinfo));
sizeof (struct res_lib_votequorum_qdisk_getinfo), -1));
if (error != CS_OK) {
goto error_exit;
@ -473,12 +470,12 @@ cs_error_t votequorum_setstate (
iov.iov_base = (char *)&req_lib_votequorum_general;
iov.iov_len = sizeof (struct req_lib_votequorum_general);
error = coroipcc_msg_send_reply_receive (
votequorum_inst->handle,
error = qb_to_cs_error(qb_ipcc_sendv_recv (
votequorum_inst->c,
&iov,
1,
&res_lib_votequorum_status,
sizeof (struct res_lib_votequorum_status));
sizeof (struct res_lib_votequorum_status), -1));
if (error != CS_OK) {
goto error_exit;
@ -513,12 +510,12 @@ cs_error_t votequorum_leaving (
iov.iov_base = (char *)&req_lib_votequorum_general;
iov.iov_len = sizeof (struct req_lib_votequorum_general);
error = coroipcc_msg_send_reply_receive (
votequorum_inst->handle,
error = qb_to_cs_error(qb_ipcc_sendv_recv (
votequorum_inst->c,
&iov,
1,
&res_lib_votequorum_status,
sizeof (struct res_lib_votequorum_status));
sizeof (struct res_lib_votequorum_status), -1));
if (error != CS_OK) {
goto error_exit;
@ -556,12 +553,12 @@ cs_error_t votequorum_trackstart (
iov.iov_base = (char *)&req_lib_votequorum_trackstart;
iov.iov_len = sizeof (struct req_lib_votequorum_trackstart);
error = coroipcc_msg_send_reply_receive (
votequorum_inst->handle,
error = qb_to_cs_error(qb_ipcc_sendv_recv (
votequorum_inst->c,
&iov,
1,
&res_lib_votequorum_status,
sizeof (struct res_lib_votequorum_status));
sizeof (struct res_lib_votequorum_status), -1));
if (error != CS_OK) {
goto error_exit;
@ -595,12 +592,12 @@ cs_error_t votequorum_trackstop (
iov.iov_base = (char *)&req_lib_votequorum_general;
iov.iov_len = sizeof (struct req_lib_votequorum_general);
error = coroipcc_msg_send_reply_receive (
votequorum_inst->handle,
error = qb_to_cs_error(qb_ipcc_sendv_recv (
votequorum_inst->c,
&iov,
1,
&res_lib_votequorum_status,
sizeof (struct res_lib_votequorum_status));
sizeof (struct res_lib_votequorum_status), -1));
if (error != CS_OK) {
goto error_exit;
@ -666,7 +663,7 @@ cs_error_t votequorum_fd_get (
return (error);
}
error = coroipcc_fd_get (votequorum_inst->handle, fd);
error = qb_to_cs_error(qb_ipcc_fd_get (votequorum_inst->c, fd));
(void)hdb_handle_put (&votequorum_handle_t_db, handle);
@ -682,9 +679,10 @@ cs_error_t votequorum_dispatch (
int cont = 1; /* always continue do loop except when set to 0 */
struct votequorum_inst *votequorum_inst;
votequorum_callbacks_t callbacks;
coroipc_response_header_t *dispatch_data;
struct qb_ipc_response_header *dispatch_data;
struct res_lib_votequorum_notification *res_lib_votequorum_notification;
struct res_lib_votequorum_expectedvotes_notification *res_lib_votequorum_expectedvotes_notification;
char dispatch_buf[IPC_DISPATCH_SIZE];
if (dispatch_types != CS_DISPATCH_ONE &&
dispatch_types != CS_DISPATCH_ALL &&
@ -707,11 +705,13 @@ cs_error_t votequorum_dispatch (
timeout = 0;
}
dispatch_data = (struct qb_ipc_response_header *)dispatch_buf;
do {
error = coroipcc_dispatch_get (
votequorum_inst->handle,
(void **)&dispatch_data,
timeout);
error = qb_to_cs_error (qb_ipcc_event_recv (
votequorum_inst->c,
dispatch_buf,
IPC_DISPATCH_SIZE,
timeout));
if (error == CS_ERR_BAD_HANDLE) {
error = CS_OK;
goto error_put;
@ -766,12 +766,10 @@ cs_error_t votequorum_dispatch (
break;
default:
coroipcc_dispatch_put (votequorum_inst->handle);
error = CS_ERR_LIBRARY;
goto error_put;
break;
}
coroipcc_dispatch_put (votequorum_inst->handle);
/*
* Determine if more messages should be processed

View File

@ -52,9 +52,7 @@ dist_man_MANS = \
corosync_overview.8 \
cpg_overview.8 \
evs_overview.8 \
logsys_overview.8 \
votequorum_overview.8 \
coroipc_overview.8 \
confdb_dispatch.3 \
confdb_fd_get.3 \
confdb_finalize.3 \

View File

@ -32,7 +32,7 @@
.\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
.\" * THE POSSIBILITY OF SUCH DAMAGE.
.\" */
.TH LOGSYS_OVERVIEW 8 2009-06-16 "corosync Man Page" "Corosync Cluster Engine Programmer's Manual"
.TH QB_LOGSYS_OVERVIEW 8 2009-06-16 "corosync Man Page" "Corosync Cluster Engine Programmer's Manual"
.SH NAME
logsys_overview \- Logsys Library Overview
.SH OVERVIEW
@ -56,14 +56,14 @@ The logsys library is initially configured by including logsys.h and declaring
a logger. Once the logger is declared, optional subsystem loggers can be
declared in every file.
The definition LOGSYS_DECLARE_SYSTEM is placed after the include section of one
The definition QB_LOGSYS_DECLARE_SYSTEM is placed after the include section of one
C file in the application. This declaration creates a constructor function
which will be called automatically before main() is executed. This technique
avoids the need for calling any setup functions in short applications that don't
require it and enables full logging capabilities before any application code is
executed.
#define LOGSYS_DECLARE_SYSTEM (name, mode, debug, file, file_priority,
#define QB_LOGSYS_DECLARE_SYSTEM (name, mode, debug, file, file_priority,
syslog_facility, syslog_priority, format, fltsize)
The name parameter is the name of the application or system.
@ -71,17 +71,17 @@ The name parameter is the name of the application or system.
The mode parameter is the logging mode of the system.
The following modes can be configured by logically ORing these flags:
LOGSYS_MODE_OUTPUT_FILE: Output all log data to the file parameter of this declaration
QB_LOGSYS_MODE_OUTPUT_FILE: Output all log data to the file parameter of this declaration
LOGSYS_MODE_OUTPUT_STDERR: Output all log data to the stderr descriptor
QB_LOGSYS_MODE_OUTPUT_STDERR: Output all log data to the stderr descriptor
LOGSYS_MODE_OUTPUT_SYSLOG: Output all log data to syslog using a non-blocking thread
QB_LOGSYS_MODE_OUTPUT_SYSLOG: Output all log data to syslog using a non-blocking thread
LOGSYS_MODE_FORK: This flags tells logsys to queue all data untill the application
QB_LOGSYS_MODE_FORK: This flags tells logsys to queue all data untill the application
has forked. The application is then responsible to call logsys_fork_completed to flush
the queue and start logging.
LOGSYS_MODE_THREADED: Starts a separate thread to handle non-blocking logging operations.
QB_LOGSYS_MODE_THREADED: Starts a separate thread to handle non-blocking logging operations.
If this flag is not specified, the logging operations are blocking.
The debug parameter, if enabled, turns off all messages priority filtering, recording
@ -110,13 +110,13 @@ An example declaration would be:
... (other #includes)
LOGSYS_DECLARE_SYSTEM ("test", /* name */
LOGSYS_MODE_OUTPUT_STDERR | LOGSYS_MODE_THREADED, /* mode */
QB_LOGSYS_DECLARE_SYSTEM ("test", /* name */
QB_LOGSYS_MODE_OUTPUT_STDERR | QB_LOGSYS_MODE_THREADED, /* mode */
0, /* debug */
NULL, /* logfile path */
LOGSYS_LEVEL_INFO, /* logfile_priority */
QB_LOGSYS_LEVEL_INFO, /* logfile_priority */
LOG_DAEMON, /* syslog facility */
LOGSYS_LEVEL_INFO, /* syslog level */
QB_LOGSYS_LEVEL_INFO, /* syslog level */
NULL, /* use default format */
1000000); /* flight recorder size */
@ -128,7 +128,7 @@ and it is entirely optional.
An example:
LOGSYS_DECLARE_SUBSYS ("subsystest");
QB_LOGSYS_DECLARE_SUBSYS ("subsystest");
It is possible to use the same subsystem name in separate object files.
In this case, the individual logging parameters for those subsystem identifier
@ -144,18 +144,18 @@ throught the configuration API.
The definition log_printf is used to log information to the log. It works
in a similiar fashion to printf, except it has a first parameter of level
which may be the following:
LOGSYS_LEVEL_EMERG
LOGSYS_LEVEL_ALERT
LOGSYS_LEVEL_CRIT
LOGSYS_LEVEL_ERR
LOGSYS_LEVEL_WARNING
LOGSYS_LEVEL_NOTICE
LOGSYS_LEVEL_INFO
LOGSYS_LEVEL_DEBUG
QB_LOGSYS_LEVEL_EMERG
QB_LOGSYS_LEVEL_ALERT
QB_LOGSYS_LEVEL_CRIT
QB_LOGSYS_LEVEL_ERR
QB_LOGSYS_LEVEL_WARNING
QB_LOGSYS_LEVEL_NOTICE
QB_LOGSYS_LEVEL_INFO
QB_LOGSYS_LEVEL_DEBUG
An example of using log_printf would be
log_printf (LOGSYS_LEVEL_EMERG, "This is an emergency %s value %d\n", string, value);
log_printf (QB_LOGSYS_LEVEL_EMERG, "This is an emergency %s value %d\n", string, value);
Tracing of functions can be done using ENTER(), LEAVE();

View File

@ -32,7 +32,7 @@ MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = libtemplate.pc.in corosync.pc.in
LIBS = cfg confdb coroipcc coroipcs cpg evs logsys pload quorum \
LIBS = cfg confdb cpg evs pload quorum \
totem_pg votequorum sam
target_LIBS = $(LIBS:%=lib%.pc)

View File

@ -48,9 +48,10 @@
#include <limits.h>
#include <errno.h>
#include <string.h>
#include <assert.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <qb/qbipc_common.h>
#include <corosync/cfg.h>
#include <corosync/list.h>
#include <corosync/mar_gen.h>
@ -329,23 +330,23 @@ __attribute__ ((constructor)) static void corosync_lcr_component_register (void)
}
struct req_exec_cfg_ringreenable {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_message_source_t source __attribute__((aligned(8)));
};
struct req_exec_cfg_killnode {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_uint32_t nodeid __attribute__((aligned(8)));
mar_name_t reason __attribute__((aligned(8)));
};
struct req_exec_cfg_crypto_set {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_uint32_t type __attribute__((aligned(8)));
};
struct req_exec_cfg_shutdown {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
};
/* IMPL */

View File

@ -41,9 +41,10 @@
#include <errno.h>
#include <unistd.h>
#include <poll.h>
#include <assert.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <qb/qbipc_common.h>
#include <corosync/corodefs.h>
#include <corosync/cfg.h>
#include <corosync/list.h>
@ -411,7 +412,7 @@ static void message_handler_req_lib_confdb_object_destroy (void *conn,
{
const struct req_lib_confdb_object_destroy *req_lib_confdb_object_destroy
= message;
coroipc_response_header_t res;
struct qb_ipc_response_header res;
int ret = CS_OK;
if (api->object_destroy(req_lib_confdb_object_destroy->object_handle))
@ -428,7 +429,7 @@ static void message_handler_req_lib_confdb_object_find_destroy (void *conn,
{
const struct req_lib_confdb_object_find_destroy
*req_lib_confdb_object_find_destroy = message;
coroipc_response_header_t res;
struct qb_ipc_response_header res;
int ret = CS_OK;
if (api->object_find_destroy(req_lib_confdb_object_find_destroy->find_handle))
@ -446,7 +447,7 @@ static void message_handler_req_lib_confdb_key_create (void *conn,
{
const struct req_lib_confdb_key_create *req_lib_confdb_key_create
= message;
coroipc_response_header_t res;
struct qb_ipc_response_header res;
int ret = CS_OK;
if (api->object_key_create(req_lib_confdb_key_create->object_handle,
@ -467,7 +468,7 @@ static void message_handler_req_lib_confdb_key_create_typed (void *conn,
{
const struct req_lib_confdb_key_create_typed *req_lib_confdb_key_create
= message;
coroipc_response_header_t res;
struct qb_ipc_response_header res;
int ret = CS_OK;
if (api->object_key_create_typed(req_lib_confdb_key_create->object_handle,
@ -581,7 +582,7 @@ static void message_handler_req_lib_confdb_key_replace (void *conn,
{
const struct req_lib_confdb_key_replace *req_lib_confdb_key_replace
= message;
coroipc_response_header_t res;
struct qb_ipc_response_header res;
int ret = CS_OK;
if (api->object_key_replace(req_lib_confdb_key_replace->object_handle,
@ -602,7 +603,7 @@ static void message_handler_req_lib_confdb_key_delete (void *conn,
{
const struct req_lib_confdb_key_delete *req_lib_confdb_key_delete
= message;
coroipc_response_header_t res;
struct qb_ipc_response_header res;
int ret = CS_OK;
if (api->object_key_delete(req_lib_confdb_key_delete->object_handle,
@ -1056,7 +1057,7 @@ static void message_handler_req_lib_confdb_track_start (void *conn,
const void *message)
{
const struct req_lib_confdb_object_track_start *req = message;
coroipc_response_header_t res;
struct qb_ipc_response_header res;
api->object_track_start(req->object_handle,
req->flags,
@ -1074,7 +1075,7 @@ static void message_handler_req_lib_confdb_track_start (void *conn,
static void message_handler_req_lib_confdb_track_stop (void *conn,
const void *message)
{
coroipc_response_header_t res;
struct qb_ipc_response_header res;
api->object_track_stop(confdb_notify_lib_of_key_change,
confdb_notify_lib_of_new_object,

View File

@ -50,12 +50,14 @@
#include <stdio.h>
#include <errno.h>
#include <time.h>
#include <assert.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/mman.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <qb/qbipc_common.h>
#include <corosync/corodefs.h>
#include <corosync/list.h>
#include <corosync/jhash.h>
@ -79,6 +81,11 @@ enum cpg_message_req_types {
MESSAGE_REQ_EXEC_CPG_DOWNLIST = 5
};
struct zcb_mapped {
struct list_head list;
void *addr;
size_t size;
};
/*
* state` exec deliver
* match group name, pid -> if matched deliver for YES:
@ -99,22 +106,22 @@ enum cpg_message_req_types {
*
*
* library accept join error codes
* UNJOINED YES(CPG_OK) set JOIN_STARTED
* LEAVE_STARTED NO(CPG_ERR_BUSY)
* JOIN_STARTED NO(CPG_ERR_EXIST)
* JOIN_COMPlETED NO(CPG_ERR_EXIST)
* UNJOINED YES(CS_OK) set JOIN_STARTED
* LEAVE_STARTED NO(CS_ERR_BUSY)
* JOIN_STARTED NO(CS_ERR_EXIST)
* JOIN_COMPlETED NO(CS_ERR_EXIST)
*
* library accept leave error codes
* UNJOINED NO(CPG_ERR_NOT_EXIST)
* LEAVE_STARTED NO(CPG_ERR_NOT_EXIST)
* JOIN_STARTED NO(CPG_ERR_BUSY)
* JOIN_COMPLETED YES(CPG_OK) set LEAVE_STARTED
* UNJOINED NO(CS_ERR_NOT_EXIST)
* LEAVE_STARTED NO(CS_ERR_NOT_EXIST)
* JOIN_STARTED NO(CS_ERR_BUSY)
* JOIN_COMPLETED YES(CS_OK) set LEAVE_STARTED
*
* library accept mcast
* UNJOINED NO(CPG_ERR_NOT_EXIST)
* LEAVE_STARTED NO(CPG_ERR_NOT_EXIST)
* JOIN_STARTED YES(CPG_OK)
* JOIN_COMPLETED YES(CPG_OK)
* UNJOINED NO(CS_ERR_NOT_EXIST)
* LEAVE_STARTED NO(CS_ERR_NOT_EXIST)
* JOIN_STARTED YES(CS_OK)
* JOIN_COMPLETED YES(CS_OK)
*/
enum cpd_state {
CPD_STATE_UNJOINED,
@ -145,6 +152,7 @@ struct cpg_pd {
int initial_totem_conf_sent;
struct list_head list;
struct list_head iteration_instance_list_head;
struct list_head zcb_mapped_list_head;
};
struct cpg_iteration_instance {
@ -254,6 +262,18 @@ static void message_handler_req_lib_cpg_iteration_finalize (
void *conn,
const void *message);
static void message_handler_req_lib_cpg_zc_alloc (
void *conn,
const void *message);
static void message_handler_req_lib_cpg_zc_free (
void *conn,
const void *message);
static void message_handler_req_lib_cpg_zc_execute (
void *conn,
const void *message);
static int cpg_node_joinleave_send (unsigned int pid, const mar_cpg_name_t *group_name, int fn, int reason);
static int cpg_exec_send_downlist(void);
@ -282,6 +302,9 @@ static int notify_lib_totem_membership (
int member_list_entries,
const unsigned int *member_list);
static inline int zcb_all_free (
struct cpg_pd *cpd);
/*
* Library Handler Definition
*/
@ -323,6 +346,20 @@ static struct corosync_lib_handler cpg_lib_engine[] =
.lib_handler_fn = message_handler_req_lib_cpg_finalize,
.flow_control = CS_LIB_FLOW_CONTROL_REQUIRED
},
{ /* 9 */
.lib_handler_fn = message_handler_req_lib_cpg_zc_alloc,
.flow_control = CS_LIB_FLOW_CONTROL_REQUIRED
},
{ /* 10 */
.lib_handler_fn = message_handler_req_lib_cpg_zc_free,
.flow_control = CS_LIB_FLOW_CONTROL_REQUIRED
},
{ /* 11 */
.lib_handler_fn = message_handler_req_lib_cpg_zc_execute,
.flow_control = CS_LIB_FLOW_CONTROL_REQUIRED
},
};
static struct corosync_exec_handler cpg_exec_engine[] =
@ -422,14 +459,14 @@ __attribute__ ((constructor)) static void corosync_lcr_component_register (void)
}
struct req_exec_cpg_procjoin {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_cpg_name_t group_name __attribute__((aligned(8)));
mar_uint32_t pid __attribute__((aligned(8)));
mar_uint32_t reason __attribute__((aligned(8)));
};
struct req_exec_cpg_mcast {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_cpg_name_t group_name __attribute__((aligned(8)));
mar_uint32_t msglen __attribute__((aligned(8)));
mar_uint32_t pid __attribute__((aligned(8)));
@ -438,13 +475,13 @@ struct req_exec_cpg_mcast {
};
struct req_exec_cpg_downlist_old {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
mar_uint32_t left_nodes __attribute__((aligned(8)));
mar_uint32_t nodeids[PROCESSOR_COUNT_MAX] __attribute__((aligned(8)));
};
struct req_exec_cpg_downlist {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
/* merge decisions */
mar_uint32_t old_members __attribute__((aligned(8)));
/* downlist below */
@ -557,7 +594,7 @@ static int notify_lib_totem_membership (
sizeof(mar_uint32_t) * (member_list_entries);
buf = alloca(size);
if (!buf)
return CPG_ERR_LIBRARY;
return CS_ERR_LIBRARY;
res = (struct res_lib_cpg_totem_confchg_callback *)buf;
res->member_list_entries = member_list_entries;
@ -577,7 +614,7 @@ static int notify_lib_totem_membership (
api->ipc_dispatch_send (conn, buf, size);
}
return CPG_OK;
return CS_OK;
}
static int notify_lib_joinlist(
@ -619,7 +656,7 @@ static int notify_lib_joinlist(
sizeof(mar_cpg_address_t) * (count + left_list_entries + joined_list_entries);
buf = alloca(size);
if (!buf)
return CPG_ERR_LIBRARY;
return CS_ERR_LIBRARY;
res = (struct res_lib_cpg_confchg_callback *)buf;
res->joined_list_entries = joined_list_entries;
@ -708,7 +745,7 @@ static int notify_lib_joinlist(
}
}
return CPG_OK;
return CS_OK;
}
static void downlist_log(int loglevel, const char *msg, struct downlist_msg* dl)
@ -848,6 +885,7 @@ static void cpg_pd_finalize (struct cpg_pd *cpd)
struct list_head *iter, *iter_next;
struct cpg_iteration_instance *cpii;
zcb_all_free(cpd);
for (iter = cpd->iteration_instance_list_head.next;
iter != &cpd->iteration_instance_list_head;
iter = iter_next) {
@ -913,8 +951,8 @@ static void exec_cpg_procjoin_endian_convert (void *msg)
static void exec_cpg_joinlist_endian_convert (void *msg_v)
{
char *msg = msg_v;
coroipc_response_header_t *res = (coroipc_response_header_t *)msg;
struct join_list_entry *jle = (struct join_list_entry *)(msg + sizeof(coroipc_response_header_t));
struct qb_ipc_response_header *res = (struct qb_ipc_response_header *)msg;
struct join_list_entry *jle = (struct join_list_entry *)(msg + sizeof(struct qb_ipc_response_header));
swab_mar_int32_t (&res->size);
@ -1126,8 +1164,8 @@ static void message_handler_req_exec_cpg_joinlist (
unsigned int nodeid)
{
const char *message = message_v;
const coroipc_response_header_t *res = (const coroipc_response_header_t *)message;
const struct join_list_entry *jle = (const struct join_list_entry *)(message + sizeof(coroipc_response_header_t));
const struct qb_ipc_response_header *res = (const struct qb_ipc_response_header *)message;
const struct join_list_entry *jle = (const struct join_list_entry *)(message + sizeof(struct qb_ipc_response_header));
log_printf(LOGSYS_LEVEL_DEBUG, "got joinlist message from node %x\n",
nodeid);
@ -1193,7 +1231,7 @@ static void message_handler_req_exec_cpg_mcast (
}
if (!known_node) {
/* Unknown node -> we will not deliver message */
log_printf(LOGSYS_LEVEL_WARNING, "Unknown node -> we will not deliver message");
return ;
}
@ -1222,7 +1260,7 @@ static int cpg_exec_send_joinlist(void)
{
int count = 0;
struct list_head *iter;
coroipc_response_header_t *res;
struct qb_ipc_response_header *res;
char *buf;
struct join_list_entry *jle;
struct iovec req_exec_cpg_iovec;
@ -1239,27 +1277,27 @@ static int cpg_exec_send_joinlist(void)
if (!count)
return 0;
buf = alloca(sizeof(coroipc_response_header_t) + sizeof(struct join_list_entry) * count);
buf = alloca(sizeof(struct qb_ipc_response_header) + sizeof(struct join_list_entry) * count);
if (!buf) {
log_printf(LOGSYS_LEVEL_WARNING, "Unable to allocate joinlist buffer");
return -1;
}
jle = (struct join_list_entry *)(buf + sizeof(coroipc_response_header_t));
res = (coroipc_response_header_t *)buf;
jle = (struct join_list_entry *)(buf + sizeof(struct qb_ipc_response_header));
res = (struct qb_ipc_response_header *)buf;
for (iter = process_info_list_head.next; iter != &process_info_list_head; iter = iter->next) {
struct process_info *pi = list_entry (iter, struct process_info, list);
if (pi->nodeid == api->totem_nodeid_get ()) {
memcpy (&jle->group_name, &pi->group, sizeof (mar_cpg_name_t));
jle->pid = pi->pid;
jle++;
if (pi->nodeid == api->totem_nodeid_get ()) {
memcpy (&jle->group_name, &pi->group, sizeof (mar_cpg_name_t));
jle->pid = pi->pid;
jle++;
}
}
res->id = SERVICE_ID_MAKE(CPG_SERVICE, MESSAGE_REQ_EXEC_CPG_JOINLIST);
res->size = sizeof(coroipc_response_header_t)+sizeof(struct join_list_entry) * count;
res->size = sizeof(struct qb_ipc_response_header)+sizeof(struct join_list_entry) * count;
req_exec_cpg_iovec.iov_base = buf;
req_exec_cpg_iovec.iov_len = res->size;
@ -1275,6 +1313,7 @@ static int cpg_lib_init_fn (void *conn)
list_add (&cpd->list, &cpg_pd_list_head);
list_init (&cpd->iteration_instance_list_head);
list_init (&cpd->zcb_mapped_list_head);
api->ipc_refcnt_inc (conn);
log_printf(LOGSYS_LEVEL_DEBUG, "lib_init_fn: conn=%p, cpd=%p\n", conn, cpd);
@ -1287,7 +1326,7 @@ static void message_handler_req_lib_cpg_join (void *conn, const void *message)
const struct req_lib_cpg_join *req_lib_cpg_join = message;
struct cpg_pd *cpd = (struct cpg_pd *)api->ipc_private_data_get (conn);
struct res_lib_cpg_join res_lib_cpg_join;
cs_error_t error = CPG_OK;
cs_error_t error = CS_OK;
struct list_head *iter;
/* Test, if we don't have same pid and group name joined */
@ -1298,7 +1337,7 @@ static void message_handler_req_lib_cpg_join (void *conn, const void *message)
mar_name_compare(&req_lib_cpg_join->group_name, &cpd_item->group_name) == 0) {
/* We have same pid and group name joined -> return error */
error = CPG_ERR_EXIST;
error = CS_ERR_EXIST;
goto response_send;
}
}
@ -1313,14 +1352,14 @@ static void message_handler_req_lib_cpg_join (void *conn, const void *message)
if (pi->nodeid == api->totem_nodeid_get () && pi->pid == req_lib_cpg_join->pid &&
mar_name_compare(&req_lib_cpg_join->group_name, &pi->group) == 0) {
/* We have same pid and group name joined -> return error */
error = CPG_ERR_TRY_AGAIN;
error = CS_ERR_TRY_AGAIN;
goto response_send;
}
}
switch (cpd->cpd_state) {
case CPD_STATE_UNJOINED:
error = CPG_OK;
error = CS_OK;
cpd->cpd_state = CPD_STATE_JOIN_STARTED;
cpd->pid = req_lib_cpg_join->pid;
cpd->flags = req_lib_cpg_join->flags;
@ -1332,13 +1371,13 @@ static void message_handler_req_lib_cpg_join (void *conn, const void *message)
MESSAGE_REQ_EXEC_CPG_PROCJOIN, CONFCHG_CPG_REASON_JOIN);
break;
case CPD_STATE_LEAVE_STARTED:
error = CPG_ERR_BUSY;
error = CS_ERR_BUSY;
break;
case CPD_STATE_JOIN_STARTED:
error = CPG_ERR_EXIST;
error = CS_ERR_EXIST;
break;
case CPD_STATE_JOIN_COMPLETED:
error = CPG_ERR_EXIST;
error = CS_ERR_EXIST;
break;
}
@ -1353,7 +1392,7 @@ response_send:
static void message_handler_req_lib_cpg_leave (void *conn, const void *message)
{
struct res_lib_cpg_leave res_lib_cpg_leave;
cs_error_t error = CPG_OK;
cs_error_t error = CS_OK;
struct req_lib_cpg_leave *req_lib_cpg_leave = (struct req_lib_cpg_leave *)message;
struct cpg_pd *cpd = (struct cpg_pd *)api->ipc_private_data_get (conn);
@ -1361,16 +1400,16 @@ static void message_handler_req_lib_cpg_leave (void *conn, const void *message)
switch (cpd->cpd_state) {
case CPD_STATE_UNJOINED:
error = CPG_ERR_NOT_EXIST;
error = CS_ERR_NOT_EXIST;
break;
case CPD_STATE_LEAVE_STARTED:
error = CPG_ERR_NOT_EXIST;
error = CS_ERR_NOT_EXIST;
break;
case CPD_STATE_JOIN_STARTED:
error = CPG_ERR_BUSY;
error = CS_ERR_BUSY;
break;
case CPD_STATE_JOIN_COMPLETED:
error = CPG_OK;
error = CS_OK;
cpd->cpd_state = CPD_STATE_LEAVE_STARTED;
cpg_node_joinleave_send (req_lib_cpg_leave->pid,
&req_lib_cpg_leave->group_name,
@ -1412,11 +1451,215 @@ static void message_handler_req_lib_cpg_finalize (
sizeof (res_lib_cpg_finalize));
}
static int
memory_map (
const char *path,
size_t bytes,
void **buf)
{
int32_t fd;
void *addr_orig;
void *addr;
int32_t res;
fd = open (path, O_RDWR, 0600);
unlink (path);
if (fd == -1) {
return (-1);
}
res = ftruncate (fd, bytes);
if (res == -1) {
goto error_close_unlink;
}
addr_orig = mmap (NULL, bytes, PROT_NONE,
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
if (addr_orig == MAP_FAILED) {
goto error_close_unlink;
}
addr = mmap (addr_orig, bytes, PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_SHARED, fd, 0);
if (addr != addr_orig) {
munmap(addr_orig, bytes);
goto error_close_unlink;
}
#ifdef COROSYNC_BSD
madvise(addr, bytes, MADV_NOSYNC);
#endif
res = close (fd);
if (res) {
return (-1);
}
*buf = addr_orig;
return (0);
error_close_unlink:
close (fd);
unlink(path);
return -1;
}
static inline int zcb_alloc (
struct cpg_pd *cpd,
const char *path_to_file,
size_t size,
void **addr)
{
struct zcb_mapped *zcb_mapped;
unsigned int res;
zcb_mapped = malloc (sizeof (struct zcb_mapped));
if (zcb_mapped == NULL) {
return (-1);
}
res = memory_map (
path_to_file,
size,
addr);
if (res == -1) {
free (zcb_mapped);
return (-1);
}
list_init (&zcb_mapped->list);
zcb_mapped->addr = *addr;
zcb_mapped->size = size;
list_add_tail (&zcb_mapped->list, &cpd->zcb_mapped_list_head);
return (0);
}
static inline int zcb_free (struct zcb_mapped *zcb_mapped)
{
unsigned int res;
res = munmap (zcb_mapped->addr, zcb_mapped->size);
list_del (&zcb_mapped->list);
free (zcb_mapped);
return (res);
}
static inline int zcb_by_addr_free (struct cpg_pd *cpd, void *addr)
{
struct list_head *list;
struct zcb_mapped *zcb_mapped;
unsigned int res = 0;
for (list = cpd->zcb_mapped_list_head.next;
list != &cpd->zcb_mapped_list_head; list = list->next) {
zcb_mapped = list_entry (list, struct zcb_mapped, list);
if (zcb_mapped->addr == addr) {
res = zcb_free (zcb_mapped);
break;
}
}
return (res);
}
static inline int zcb_all_free (
struct cpg_pd *cpd)
{
struct list_head *list;
struct zcb_mapped *zcb_mapped;
for (list = cpd->zcb_mapped_list_head.next;
list != &cpd->zcb_mapped_list_head;) {
zcb_mapped = list_entry (list, struct zcb_mapped, list);
list = list->next;
zcb_free (zcb_mapped);
}
return (0);
}
union u {
uint64_t server_addr;
void *server_ptr;
};
static uint64_t void2serveraddr (void *server_ptr)
{
union u u;
u.server_ptr = server_ptr;
return (u.server_addr);
}
static void *serveraddr2void (uint64_t server_addr)
{
union u u;
u.server_addr = server_addr;
return (u.server_ptr);
};
static void message_handler_req_lib_cpg_zc_alloc (
void *conn,
const void *message)
{
mar_req_coroipcc_zc_alloc_t *hdr = (mar_req_coroipcc_zc_alloc_t *)message;
struct qb_ipc_response_header res_header;
void *addr = NULL;
struct coroipcs_zc_header *zc_header;
unsigned int res;
struct cpg_pd *cpd = (struct cpg_pd *)api->ipc_private_data_get (conn);
log_printf(LOGSYS_LEVEL_DEBUG, "path: %s", hdr->path_to_file);
res = zcb_alloc (cpd, hdr->path_to_file, hdr->map_size,
&addr);
assert(res == 0);
zc_header = (struct coroipcs_zc_header *)addr;
zc_header->server_address = void2serveraddr(addr);
res_header.size = sizeof (struct qb_ipc_response_header);
res_header.id = 0;
api->ipc_response_send (conn,
&res_header,
res_header.size);
}
static void message_handler_req_lib_cpg_zc_free (
void *conn,
const void *message)
{
mar_req_coroipcc_zc_free_t *hdr = (mar_req_coroipcc_zc_free_t *)message;
struct qb_ipc_response_header res_header;
void *addr = NULL;
struct cpg_pd *cpd = (struct cpg_pd *)api->ipc_private_data_get (conn);
log_printf(LOGSYS_LEVEL_DEBUG, " free'ing");
addr = serveraddr2void (hdr->server_address);
zcb_by_addr_free (cpd, addr);
res_header.size = sizeof (struct qb_ipc_response_header);
res_header.id = 0;
api->ipc_response_send (
conn, &res_header,
res_header.size);
}
/* Mcast message from the library */
static void message_handler_req_lib_cpg_mcast (void *conn, const void *message)
{
const struct req_lib_cpg_mcast *req_lib_cpg_mcast = message;
struct cpg_pd *cpd = (struct cpg_pd *)api->ipc_private_data_get (conn);
struct cpg_pd *cpd = (struct cpg_pd *)api->ipc_private_data_get (conn);
mar_cpg_name_t group_name = cpd->group_name;
struct iovec req_exec_cpg_iovec[2];
@ -1424,49 +1667,117 @@ static void message_handler_req_lib_cpg_mcast (void *conn, const void *message)
struct res_lib_cpg_mcast res_lib_cpg_mcast;
int msglen = req_lib_cpg_mcast->msglen;
int result;
cs_error_t error = CPG_ERR_NOT_EXIST;
cs_error_t error = CS_ERR_NOT_EXIST;
log_printf(LOGSYS_LEVEL_DEBUG, "got mcast request on %p\n", conn);
switch (cpd->cpd_state) {
case CPD_STATE_UNJOINED:
error = CPG_ERR_NOT_EXIST;
break;
case CPD_STATE_LEAVE_STARTED:
error = CPG_ERR_NOT_EXIST;
break;
case CPD_STATE_JOIN_STARTED:
error = CPG_OK;
break;
case CPD_STATE_JOIN_COMPLETED:
error = CPG_OK;
break;
switch (cpd->cpd_state) {
case CPD_STATE_UNJOINED:
error = CS_ERR_NOT_EXIST;
break;
case CPD_STATE_LEAVE_STARTED:
error = CS_ERR_NOT_EXIST;
break;
case CPD_STATE_JOIN_STARTED:
error = CS_OK;
break;
case CPD_STATE_JOIN_COMPLETED:
error = CS_OK;
break;
}
if (error == CPG_OK) {
req_exec_cpg_mcast.header.size = sizeof(req_exec_cpg_mcast) + msglen;
req_exec_cpg_mcast.header.id = SERVICE_ID_MAKE(CPG_SERVICE,
MESSAGE_REQ_EXEC_CPG_MCAST);
req_exec_cpg_mcast.pid = cpd->pid;
req_exec_cpg_mcast.msglen = msglen;
api->ipc_source_set (&req_exec_cpg_mcast.source, conn);
memcpy(&req_exec_cpg_mcast.group_name, &group_name,
sizeof(mar_cpg_name_t));
if (error == CS_OK) {
req_exec_cpg_mcast.header.size = sizeof(req_exec_cpg_mcast) + msglen;
req_exec_cpg_mcast.header.id = SERVICE_ID_MAKE(CPG_SERVICE,
MESSAGE_REQ_EXEC_CPG_MCAST);
req_exec_cpg_mcast.pid = cpd->pid;
req_exec_cpg_mcast.msglen = msglen;
api->ipc_source_set (&req_exec_cpg_mcast.source, conn);
memcpy(&req_exec_cpg_mcast.group_name, &group_name,
sizeof(mar_cpg_name_t));
req_exec_cpg_iovec[0].iov_base = (char *)&req_exec_cpg_mcast;
req_exec_cpg_iovec[0].iov_len = sizeof(req_exec_cpg_mcast);
req_exec_cpg_iovec[1].iov_base = (char *)&req_lib_cpg_mcast->message;
req_exec_cpg_iovec[1].iov_len = msglen;
req_exec_cpg_iovec[0].iov_base = (char *)&req_exec_cpg_mcast;
req_exec_cpg_iovec[0].iov_len = sizeof(req_exec_cpg_mcast);
req_exec_cpg_iovec[1].iov_base = (char *)&req_lib_cpg_mcast->message;
req_exec_cpg_iovec[1].iov_len = msglen;
result = api->totem_mcast (req_exec_cpg_iovec, 2, TOTEM_AGREED);
assert(result == 0);
}
result = api->totem_mcast (req_exec_cpg_iovec, 2, TOTEM_AGREED);
assert(result == 0);
}
res_lib_cpg_mcast.header.size = sizeof(res_lib_cpg_mcast);
res_lib_cpg_mcast.header.id = MESSAGE_RES_CPG_MCAST;
res_lib_cpg_mcast.header.error = error;
api->ipc_response_send (conn, &res_lib_cpg_mcast,
sizeof (res_lib_cpg_mcast));
res_lib_cpg_mcast.header.error = error;
api->ipc_response_send (conn, &res_lib_cpg_mcast,
sizeof (res_lib_cpg_mcast));
}
static void message_handler_req_lib_cpg_zc_execute (
void *conn,
const void *message)
{
mar_req_coroipcc_zc_execute_t *hdr = (mar_req_coroipcc_zc_execute_t *)message;
struct qb_ipc_request_header *header;
struct res_lib_cpg_mcast res_lib_cpg_mcast;
struct cpg_pd *cpd = (struct cpg_pd *)api->ipc_private_data_get (conn);
struct iovec req_exec_cpg_iovec[2];
struct req_exec_cpg_mcast req_exec_cpg_mcast;
struct req_lib_cpg_mcast *req_lib_cpg_mcast;
int result;
cs_error_t error = CS_ERR_NOT_EXIST;
struct coroipcs_zc_header *zc_hdr;
log_printf(LOGSYS_LEVEL_DEBUG, "got ZC mcast request on %p\n", conn);
zc_hdr = (struct coroipcs_zc_header *)((char *)serveraddr2void(hdr->server_address));
header = (struct qb_ipc_request_header *)(((char *)serveraddr2void(hdr->server_address) + sizeof (struct coroipcs_zc_header)));
req_lib_cpg_mcast = (struct req_lib_cpg_mcast *)header;
switch (cpd->cpd_state) {
case CPD_STATE_UNJOINED:
error = CS_ERR_NOT_EXIST;
break;
case CPD_STATE_LEAVE_STARTED:
error = CS_ERR_NOT_EXIST;
break;
case CPD_STATE_JOIN_STARTED:
error = CS_OK;
break;
case CPD_STATE_JOIN_COMPLETED:
error = CS_OK;
break;
}
res_lib_cpg_mcast.header.size = sizeof(res_lib_cpg_mcast);
res_lib_cpg_mcast.header.id = MESSAGE_RES_CPG_MCAST;
if (error == CS_OK) {
req_exec_cpg_mcast.header.size = sizeof(req_exec_cpg_mcast) + req_lib_cpg_mcast->msglen;
req_exec_cpg_mcast.header.id = SERVICE_ID_MAKE(CPG_SERVICE,
MESSAGE_REQ_EXEC_CPG_MCAST);
req_exec_cpg_mcast.pid = cpd->pid;
req_exec_cpg_mcast.msglen = req_lib_cpg_mcast->msglen;
api->ipc_source_set (&req_exec_cpg_mcast.source, conn);
memcpy(&req_exec_cpg_mcast.group_name, &cpd->group_name,
sizeof(mar_cpg_name_t));
req_exec_cpg_iovec[0].iov_base = (char *)&req_exec_cpg_mcast;
req_exec_cpg_iovec[0].iov_len = sizeof(req_exec_cpg_mcast);
req_exec_cpg_iovec[1].iov_base = (char *)header + sizeof(struct req_lib_cpg_mcast);
req_exec_cpg_iovec[1].iov_len = req_exec_cpg_mcast.msglen;
result = api->totem_mcast (req_exec_cpg_iovec, 2, TOTEM_AGREED);
if (result == 0) {
res_lib_cpg_mcast.header.error = CS_OK;
} else {
res_lib_cpg_mcast.header.error = CS_ERR_TRY_AGAIN;
}
} else {
res_lib_cpg_mcast.header.error = error;
}
api->ipc_response_send (conn, &res_lib_cpg_mcast,
sizeof (res_lib_cpg_mcast));
}
static void message_handler_req_lib_cpg_membership (void *conn,
@ -1479,7 +1790,7 @@ static void message_handler_req_lib_cpg_membership (void *conn,
int member_count = 0;
res_lib_cpg_membership_get.header.id = MESSAGE_RES_CPG_MEMBERSHIP;
res_lib_cpg_membership_get.header.error = CPG_OK;
res_lib_cpg_membership_get.header.error = CS_OK;
res_lib_cpg_membership_get.header.size =
sizeof (struct req_lib_cpg_membership_get);
@ -1506,7 +1817,7 @@ static void message_handler_req_lib_cpg_local_get (void *conn,
res_lib_cpg_local_get.header.size = sizeof (res_lib_cpg_local_get);
res_lib_cpg_local_get.header.id = MESSAGE_RES_CPG_LOCAL_GET;
res_lib_cpg_local_get.header.error = CPG_OK;
res_lib_cpg_local_get.header.error = CS_OK;
res_lib_cpg_local_get.local_nodeid = api->totem_nodeid_get ();
api->ipc_response_send (conn, &res_lib_cpg_local_get,

View File

@ -46,13 +46,14 @@
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <assert.h>
#include <time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <corosync/swab.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <qb/qbipc_common.h>
#include <corosync/corodefs.h>
#include <corosync/mar_gen.h>
#include <corosync/lcr/lcr_comp.h>

View File

@ -50,10 +50,13 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <assert.h>
#include <qb/qblist.h>
#include <qb/qbipc_common.h>
#include <corosync/swab.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <corosync/corodefs.h>
#include <corosync/lcr/lcr_comp.h>
#include <corosync/mar_gen.h>
@ -116,7 +119,7 @@ static unsigned int msgs_sent = 0;
static struct corosync_api_v1 *api;
struct req_exec_pload_start {
coroipc_request_header_t header;
struct qb_ipc_request_header header;
unsigned int msg_code;
unsigned int msg_count;
unsigned int msg_size;
@ -124,7 +127,7 @@ struct req_exec_pload_start {
};
struct req_exec_pload_mcast {
coroipc_request_header_t header;
struct qb_ipc_request_header header;
unsigned int msg_code;
};

View File

@ -55,7 +55,7 @@
#include <time.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <qb/qbipc_common.h>
#include <corosync/corodefs.h>
#include <corosync/engine/logsys.h>

View File

@ -56,7 +56,7 @@
#include <arpa/inet.h>
#include <corosync/corotypes.h>
#include <corosync/coroipc_types.h>
#include <qb/qbipc_common.h>
#include <corosync/corodefs.h>
#include <corosync/cfg.h>
#include <corosync/list.h>
@ -391,7 +391,7 @@ static void votequorum_init(struct corosync_api_v1 *api,
}
struct req_exec_quorum_nodeinfo {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
unsigned int first_trans;
unsigned int votes;
unsigned int expected_votes;
@ -410,14 +410,14 @@ struct req_exec_quorum_nodeinfo {
#define RECONFIG_PARAM_LEAVING 3
struct req_exec_quorum_reconfigure {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
unsigned int param;
unsigned int nodeid;
unsigned int value;
};
struct req_exec_quorum_killnode {
coroipc_request_header_t header __attribute__((aligned(8)));
struct qb_ipc_request_header header __attribute__((aligned(8)));
unsigned int reason;
unsigned int nodeid;
};

View File

@ -35,44 +35,45 @@ INCLUDES = -I$(top_builddir)/include/corosync -I$(top_srcdir)/include
noinst_PROGRAMS = testevs evsbench evsverify cpgverify testcpg testcpg2 cpgbench testconfdb \
logsysbench logsysrec testquorum testvotequorum1 testvotequorum2 \
logsys_s logsys_t1 logsys_t2 testcpgzc cpgbenchzc testzcgc \
stress_cpgzc stress_cpgfdget stress_cpgcontext cpgbound testsam
logsys_s logsys_t1 logsys_t2 \
stress_cpgfdget stress_cpgcontext cpgbound testsam \
testcpgzc cpgbenchzc testzcgc stress_cpgzc
testevs_LDADD = -levs -lcoroipcc $(LIBQB_LIBS)
testevs_LDADD = -levs $(LIBQB_LIBS)
testevs_LDFLAGS = -L../lib
testcpg_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
testcpg_LDADD = -lcpg $(LIBQB_LIBS)
testcpg_LDFLAGS = -L../lib
testcpg2_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
testcpg2_LDADD = -lcpg $(LIBQB_LIBS)
testcpg2_LDFLAGS = -L../lib
testcpgzc_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
testcpgzc_LDADD = -lcpg $(LIBQB_LIBS)
testcpgzc_LDFLAGS = -L../lib
testzcgc_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
testzcgc_LDADD = -lcpg $(LIBQB_LIBS)
testzcgc_LDFLAGS = -L../lib
stress_cpgzc_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
stress_cpgzc_LDADD = -lcpg $(LIBQB_LIBS)
stress_cpgzc_LDFLAGS = -L../lib
stress_cpgfdget_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
stress_cpgfdget_LDADD = -lcpg $(LIBQB_LIBS)
stress_cpgfdget_LDFLAGS = -L../lib
stress_cpgcontext_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
stress_cpgcontext_LDADD = -lcpg $(LIBQB_LIBS)
stress_cpgcontext_LDFLAGS = -L../lib
testconfdb_LDADD = -lconfdb ../lcr/liblcr.a -lcoroipcc $(LIBQB_LIBS)
testconfdb_LDADD = -lconfdb ../lcr/liblcr.a $(LIBQB_LIBS)
testconfdb_LDFLAGS = -L../lib
testquorum_LDADD = -lquorum -lcoroipcc $(LIBQB_LIBS)
testquorum_LDADD = -lquorum $(LIBQB_LIBS)
testquorum_LDFLAGS = -L../lib
testvotequorum1_LDADD = -lvotequorum -lcoroipcc $(LIBQB_LIBS)
testvotequorum1_LDADD = -lvotequorum $(LIBQB_LIBS)
testvotequorum1_LDFLAGS = -L../lib
testvotequorum2_LDADD = -lvotequorum -lcoroipcc $(LIBQB_LIBS)
testvotequorum2_LDADD = -lvotequorum $(LIBQB_LIBS)
testvotequorum2_LDFLAGS = -L../lib
evsverify_LDADD = -levs -ltotem_pg -lcoroipcc $(LIBQB_LIBS)
evsverify_LDADD = -levs -ltotem_pg $(LIBQB_LIBS)
evsverify_LDFLAGS = -L../lib -L../exec
cpgverify_LDADD = -lcpg -ltotem_pg -lcoroipcc $(LIBQB_LIBS)
cpgverify_LDADD = -lcpg -ltotem_pg $(LIBQB_LIBS)
cpgverify_LDFLAGS = -L../lib -L../exec
cpgbound_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
cpgbound_LDADD = -lcpg $(LIBQB_LIBS)
cpgbound_LDFLAGS = -L../lib
evsbench_LDADD = -levs -lcoroipcc $(LIBQB_LIBS)
evsbench_LDADD = -levs $(LIBQB_LIBS)
evsbench_LDFLAGS = -L../lib
cpgbench_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
cpgbench_LDADD = -lcpg $(LIBQB_LIBS)
cpgbench_LDFLAGS = -L../lib
cpgbenchzc_LDADD = -lcpg -lcoroipcc $(LIBQB_LIBS)
cpgbenchzc_LDADD = -lcpg $(LIBQB_LIBS)
cpgbenchzc_LDFLAGS = -L../lib
logsysbench_LDADD = -llogsys
logsysbench_LDFLAGS = -L../exec
@ -85,7 +86,7 @@ logsys_t1_LDADD = -llogsys
logsys_t1_LDFLAGS = -L../exec
logsys_t2_LDADD = -llogsys
logsys_t2_LDFLAGS = -L../exec
testsam_LDADD = -lsam -lconfdb -lquorum -lcoroipcc
testsam_LDADD = -lsam -lconfdb -lquorum $(LIBQB_LIBS)
testsam_LDFLAGS = -L../lib
LINT_FILES1:=$(filter-out sa_error.c, $(wildcard *.c))

View File

@ -50,10 +50,17 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <qb/qbutil.h>
#include <corosync/corotypes.h>
#include <corosync/cpg.h>
static cpg_handle_t handle;
static pthread_t thread;
#ifndef timersub
#define timersub(a, b, result) \
do { \
@ -69,7 +76,7 @@
static int alarm_notice;
static void cpg_bm_confchg_fn (
cpg_handle_t handle,
cpg_handle_t handle_in,
const struct cpg_name *group_name,
const struct cpg_address *member_list, size_t member_list_entries,
const struct cpg_address *left_list, size_t left_list_entries,
@ -80,7 +87,7 @@ static void cpg_bm_confchg_fn (
static unsigned int write_count;
static void cpg_bm_deliver_fn (
cpg_handle_t handle,
cpg_handle_t handle_in,
const struct cpg_name *group_name,
uint32_t nodeid,
uint32_t pid,
@ -98,13 +105,12 @@ static cpg_callbacks_t callbacks = {
static char data[500000];
static void cpg_benchmark (
cpg_handle_t handle,
cpg_handle_t handle_in,
int write_size)
{
struct timeval tv1, tv2, tv_elapsed;
struct iovec iov;
unsigned int res;
cpg_flow_control_state_t flow_control_state;
alarm_notice = 0;
iov.iov_base = data;
@ -115,23 +121,8 @@ static void cpg_benchmark (
gettimeofday (&tv1, NULL);
do {
/*
* Test checkpoint write
*/
cpg_flow_control_state_get (handle, &flow_control_state);
if (flow_control_state == CPG_FLOW_CONTROL_DISABLED) {
retry:
res = cpg_mcast_joined (handle, CPG_TYPE_AGREED, &iov, 1);
if (res == CS_ERR_TRY_AGAIN) {
goto retry;
}
}
res = cpg_dispatch (handle, CS_DISPATCH_ALL);
if (res != CS_OK) {
printf ("cpg dispatch returned error %d\n", res);
exit (1);
}
} while (alarm_notice == 0);
res = cpg_mcast_joined (handle_in, CPG_TYPE_AGREED, &iov, 1);
} while (alarm_notice == 0 && (res == CS_OK || res == CS_ERR_TRY_AGAIN));
gettimeofday (&tv2, NULL);
timersub (&tv2, &tv1, &tv_elapsed);
@ -155,19 +146,35 @@ static struct cpg_name group_name = {
.length = 6
};
static void libqb_log_writer(const char *file_name,
int32_t file_line,
int32_t severity, const char *msg)
{
printf("libqb: %s:%d [%d] %s\n", file_name, file_line, severity, msg);
}
static void* dispatch_thread (void *arg)
{
cpg_dispatch (handle, CPG_DISPATCH_BLOCKING);
return NULL;
}
int main (void) {
cpg_handle_t handle;
unsigned int size;
int i;
unsigned int res;
size = 1000;
qb_util_set_log_function(libqb_log_writer);
size = 64;
signal (SIGALRM, sigalrm_handler);
res = cpg_initialize (&handle, &callbacks);
if (res != CS_OK) {
printf ("cpg_initialize failed with result %d\n", res);
exit (1);
}
pthread_create (&thread, NULL, dispatch_thread, NULL);
res = cpg_join (handle, &group_name);
if (res != CS_OK) {
@ -175,10 +182,10 @@ int main (void) {
exit (1);
}
for (i = 0; i < 50; i++) { /* number of repetitions - up to 50k */
for (i = 0; i < 10; i++) { /* number of repetitions - up to 50k */
cpg_benchmark (handle, size);
signal (SIGALRM, sigalrm_handler);
size += 1000;
size *= 2;
}
res = cpg_finalize (handle);

View File

@ -39,6 +39,7 @@
#include <config.h>
#include <limits.h>
#include <pthread.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdint.h>

View File

@ -42,16 +42,17 @@ bin_SCRIPTS = corosync-blackbox
EXTRA_DIST = $(bin_SCRIPTS) corosync-notifyd.sysconfig.example
corosync_pload_LDADD = -lpload -lcoroipcc $(LIBQB_LIBS)
corosync_fplay_LDADD = $(LIBQB_LIBS)
corosync_pload_LDADD = -lpload $(LIBQB_LIBS)
corosync_pload_LDFLAGS = -L../lib
corosync_objctl_LDADD = -lconfdb ../lcr/liblcr.a -lcoroipcc $(LIBQB_LIBS)
corosync_objctl_LDADD = -lconfdb ../lcr/liblcr.a $(LIBQB_LIBS)
corosync_objctl_LDFLAGS = -L../lib
corosync_cfgtool_LDADD = -lcfg -lcoroipcc $(LIBQB_LIBS)
corosync_cfgtool_LDADD = -lcfg $(LIBQB_LIBS)
corosync_cfgtool_LDFLAGS= -L../lib
corosync_cpgtool_LDADD = -lcfg -lcpg -lcoroipcc $(LIBQB_LIBS)
corosync_cpgtool_LDADD = -lcfg -lcpg $(LIBQB_LIBS)
corosync_cpgtool_LDFLAGS= -L../lib
corosync_quorumtool_LDADD = -lconfdb -lcfg -lquorum \
-lvotequorum -lcoroipcc ../lcr/liblcr.a $(LIBQB_LIBS)
-lvotequorum ../lcr/liblcr.a $(LIBQB_LIBS)
corosync_quorumtool_LDFLAGS = -L../lib
corosync_notifyd_LDADD = -lcfg -lconfdb ../lcr/liblcr.a -lcoroipcc \