Przeglądaj źródła

Abstracted Shared Memory IPC library

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1885 fd59a12c-fef9-0310-b244-a6a79926bd2f
Steven Dake 17 lat temu
rodzic
commit
c5fc824d7f

+ 3 - 2
configure.ac

@@ -7,7 +7,7 @@ AC_PREREQ([2.61])
 AC_INIT([corosync], [0.95], [openais@lists.osdl.org])
 AM_INIT_AUTOMAKE
 
-AC_CONFIG_SRCDIR([lib/coroipc.c])
+AC_CONFIG_SRCDIR([lib/coroipcc.c])
 AC_CONFIG_HEADER([include/corosync/config.h include/corosync/cs_config.h])
 
 AC_CANONICAL_HOST
@@ -79,7 +79,8 @@ AC_FUNC_VPRINTF
 AC_CHECK_FUNCS([alarm alphasort atexit bzero dup2 endgrent endpwent fcntl \
 		getcwd getpeerucred gettimeofday inet_ntoa memmove memset \
 		mkdir scandir select socket strcasecmp strchr strdup \
-		strerror strrchr strspn strstr])
+		strerror strrchr strspn strstr pthread_spin_lock \
+		pthread_spin_unlock])
 
 # add man and init dirs?
 AC_CONFIG_FILES([Makefile

+ 18 - 5
exec/Makefile.am

@@ -38,31 +38,34 @@ INCLUDES		= -I$(top_builddir)/include -I$(top_srcdir)/include
 TOTEM_SRC		= coropoll.c totemip.c totemnet.c totemrrp.c \
 			  totemsrp.c totemmrp.c totempg.c crypto.c wthread.c
 LOGSYS_SRC		= wthread.c logsys.c
+COROIPCS_SRC		= coroipcs.c coroipcs.h
 
 LCRSO_SRC		= objdb.c vsf_ykd.c coroparse.c quorum.c vsf_quorum.c
 LCRSO_OBJS		= $(LCRSO_SRC:%.c=%.o)
 LCRSO			= $(LCRSO_SRC:%.c=%.lcrso)
 
-lib_LIBRARIES		= libtotem_pg.a liblogsys.a
+lib_LIBRARIES		= libtotem_pg.a liblogsys.a libcoroipcs.a
 sbin_PROGRAMS		= corosync
 
 libtotem_pg_a_SOURCES	= $(TOTEM_SRC)
 liblogsys_a_SOURCES	= $(LOGSYS_SRC)
+libcoroipcs_a_SOURCES	= $(COROIPCS_SRC)
 
-corosync_SOURCES 	= main.c mempool.c util.c sync.c apidef.c service.c ipc.c \
+corosync_SOURCES 	= main.c mempool.c util.c sync.c apidef.c service.c \
 			  timer.c totemconfig.c mainconfig.c quorum.c ../lcr/lcr_ifact.c
-corosync_LDADD	  	= -ltotem_pg -llogsys
-corosync_DEPENDENCIES	= libtotem_pg.so.$(SONAME) liblogsys.so.$(SONAME)
+corosync_LDADD	  	= -ltotem_pg -llogsys -lcoroipcs
+corosync_DEPENDENCIES	= libtotem_pg.so.$(SONAME) liblogsys.so.$(SONAME) libcoroipcs.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)
 SHARED_LIBS_SO_TWO	= $(SHARED_LIBS:%.so.$(SONAME)=%.so.$(SOMAJOR))
 
-noinst_HEADERS		= apidef.h crypto.h ipc.h mainconfig.h main.h mempool.h \
+noinst_HEADERS		= apidef.h crypto.h mainconfig.h main.h mempool.h \
 			  quorum.h service.h sync.h timer.h tlist.h totemconfig.h \
 			  totemmrp.h totemnet.h totemrrp.h totemsrp.h util.h \
 			  version.h vsf.h wthread.h
@@ -79,6 +82,9 @@ libtotem_pg.so.$(SONAME): $(TOTEM_OBJS)
 liblogsys.so.$(SONAME): $(LOGSYS_OBJS)
 	$(CC) $(LDFLAGS) $(DARWIN_OPTS) $(LOGSYS_OBJS) -o $@ -lpthread
 
+libcoroipcs.so.$(SONAME): $(COROIPCS_OBJS)
+	$(CC) $(LDFLAGS) $(DARWIN_OPTS) $(COROIPCS_OBJS) -o $@ -lpthread
+
 else
 
 %.lcrso: %.o
@@ -98,6 +104,13 @@ 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
 
 lint:

+ 8 - 8
exec/apidef.c

@@ -46,7 +46,7 @@
 #include <corosync/totem/totempg.h>
 #include <corosync/totem/totemip.h>
 #include "main.h"
-#include "ipc.h"
+#include "coroipcs.h"
 #include "sync.h"
 #include "quorum.h"
 #include <corosync/engine/coroapi.h>
@@ -77,13 +77,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 = cs_conn_private_data_get,
-	.ipc_response_iov_send = cs_response_iov_send,
-	.ipc_response_send = cs_response_send,
-	.ipc_dispatch_send = cs_dispatch_send,
-	.ipc_dispatch_iov_send = cs_dispatch_iov_send,
-	.ipc_refcnt_inc =  cs_conn_refcount_inc,
-	.ipc_refcnt_dec = cs_conn_refcount_dec,
+	.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,
 	.totem_nodeid_get = totempg_my_nodeid_get,
 	.totem_family_get = totempg_my_family_get,
 	.totem_ring_reenable = totempg_ring_reenable,

+ 297 - 373
exec/ipc.c → exec/coroipcs.c

@@ -66,33 +66,11 @@
 
 #include <sys/shm.h>
 #include <sys/sem.h>
-#include <corosync/swab.h>
 #include <corosync/corotypes.h>
 #include <corosync/list.h>
-#include <corosync/queue.h>
-#include <corosync/lcr/lcr_ifact.h>
-#include <corosync/totem/coropoll.h>
-#include <corosync/totem/totempg.h>
-#include <corosync/engine/objdb.h>
-#include <corosync/engine/config.h>
-#include <corosync/engine/logsys.h>
-
-#include "quorum.h"
-#include "poll.h"
-#include "totemsrp.h"
-#include "mempool.h"
-#include "mainconfig.h"
-#include "totemconfig.h"
-#include "main.h"
-#include "tlist.h"
-#include "ipc.h"
-#include "sync.h"
-#include <corosync/engine/coroapi.h>
-#include "service.h"
-
-LOGSYS_DECLARE_SUBSYS ("IPC", LOG_INFO);
-
-#include "util.h"
+
+#include "coroipcs.h"
+#include <corosync/ipc_gen.h>
 
 #ifdef COROSYNC_SOLARIS
 #define MSG_NOSIGNAL 0
@@ -103,11 +81,7 @@ LOGSYS_DECLARE_SUBSYS ("IPC", LOG_INFO);
 #define MSG_SEND_LOCKED		0
 #define MSG_SEND_UNLOCKED	1
 
-static unsigned int g_gid_valid = 0;
-
-static void (*ipc_serialize_lock_fn) (void);
-
-static void (*ipc_serialize_unlock_fn) (void);
+static struct coroipcs_init_state *api;
 
 DECLARE_LIST_INIT (conn_info_list_head);
 
@@ -152,10 +126,10 @@ struct conn_info {
 	struct shared_memory *mem;
 	struct list_head outq_head;
 	void *private_data;
-	int (*lib_exit_fn) (void *conn);
 	struct list_head list;
 	char setup_msg[sizeof (mar_req_setup_t)];
 	unsigned int setup_bytes_read;
+	char *sending_allowed_private_data[64];
 };
 
 static int shared_mem_dispatch_bytes_left (struct conn_info *conn_info);
@@ -220,7 +194,7 @@ static inline int conn_info_destroy (struct conn_info *conn_info)
 		conn_info->state == CONN_STATE_DISCONNECT_INACTIVE) {
 		list_del (&conn_info->list);
 		close (conn_info->fd);
-		free (conn_info);
+		api->free (conn_info);
 		return (-1);
 	}
 
@@ -229,12 +203,14 @@ static inline int conn_info_destroy (struct conn_info *conn_info)
 		return (0);
 	}
 
+	api->serialize_lock ();
 	/*
 	 * Retry library exit function if busy
 	 */
 	if (conn_info->state == CONN_STATE_THREAD_DESTROYED) {
-		res = ais_service[conn_info->service]->lib_exit_fn (conn_info);
+		res = api->exit_fn_get (conn_info->service) (conn_info);
 		if (res == -1) {
+			api->serialize_unlock ();
 			return (0);
 		} else {
 			conn_info->state = CONN_STATE_LIB_EXIT_CALLED;
@@ -244,6 +220,7 @@ static inline int conn_info_destroy (struct conn_info *conn_info)
 	pthread_mutex_lock (&conn_info->mutex);
 	if (conn_info->refcount > 0) {
 		pthread_mutex_unlock (&conn_info->mutex);
+		api->serialize_unlock ();
 		return (0);
 	}
 	list_del (&conn_info->list);
@@ -260,10 +237,11 @@ static inline int conn_info_destroy (struct conn_info *conn_info)
 	 * Free allocated data needed to retry exiting library IPC connection
 	 */
 	if (conn_info->private_data) {
-		free (conn_info->private_data);
+		api->free (conn_info->private_data);
 	}
 	close (conn_info->fd);
-	free (conn_info);
+	api->free (conn_info);
+	api->serialize_unlock ();
 	return (-1);
 }
 
@@ -279,9 +257,7 @@ static void *pthread_ipc_consumer (void *conn)
 	int res;
 	mar_req_header_t *header;
 	struct res_overlay res_overlay;
-	struct iovec send_ok_joined_iovec;
-	int send_ok = 0;
-	int reserved_msgs = 0;
+	int send_ok;
 
 	for (;;) {
 		sop.sem_num = 0;
@@ -289,7 +265,7 @@ static void *pthread_ipc_consumer (void *conn)
 		sop.sem_flg = 0;
 retry_semop:
 		if (ipc_thread_active (conn_info) == 0) {
-			cs_conn_refcount_dec (conn_info);
+			coroipcs_refcount_dec (conn_info);
 			pthread_exit (0);
 		}
 		res = semop (conn_info->semid, &sop, 1);
@@ -297,47 +273,38 @@ retry_semop:
 			goto retry_semop;
 		} else
 		if ((res == -1) && (errno == EINVAL || errno == EIDRM)) {
-			cs_conn_refcount_dec (conn_info);
+			coroipcs_refcount_dec (conn_info);
 			pthread_exit (0);
 		}
 
-		cs_conn_refcount_inc (conn_info);
-
-		header = (mar_req_header_t *)conn_info->mem->req_buffer;
+		coroipcs_refcount_inc (conn_info);
 
-		send_ok_joined_iovec.iov_base = (char *)header;
-		send_ok_joined_iovec.iov_len = header->size;
-
-		reserved_msgs = totempg_groups_joined_reserve (
-			corosync_group_handle,
-			&send_ok_joined_iovec, 1);
-
-		send_ok =
-			(corosync_quorum_is_quorate() == 1 || ais_service[conn_info->service]->allow_inquorate == CS_LIB_ALLOW_INQUORATE) && (
-			(ais_service[conn_info->service]->lib_engine[header->id].flow_control == CS_LIB_FLOW_CONTROL_NOT_REQUIRED) ||
-			((ais_service[conn_info->service]->lib_engine[header->id].flow_control == CS_LIB_FLOW_CONTROL_REQUIRED) &&
-			(reserved_msgs) &&
-			(sync_in_process() == 0)));
+                header = (mar_req_header_t *)conn_info->mem->req_buffer;
 
+		send_ok = api->sending_allowed (conn_info->service,
+			header->id,
+			header,	
+			conn_info->sending_allowed_private_data);
+	
 		if (send_ok) {
-			ipc_serialize_lock_fn();
-			ais_service[conn_info->service]->lib_engine[header->id].lib_handler_fn (conn_info, header);
-			ipc_serialize_unlock_fn();
+			api->serialize_lock();
+			api->handler_fn_get (conn_info->service, header->id) (conn_info, header);
+			api->serialize_unlock();
 		} else {
 			/*
 			 * Overload, tell library to retry
 			 */
 			res_overlay.header.size =
-					ais_service[conn_info->service]->lib_engine[header->id].response_size;
+				api->response_size_get (conn_info->service, header->id);
 			res_overlay.header.id =
-				ais_service[conn_info->service]->lib_engine[header->id].response_id;
+				api->response_id_get (conn_info->service, header->id);
 			res_overlay.header.error = CS_ERR_TRY_AGAIN;
-			cs_response_send (conn_info, &res_overlay, 
+			coroipcs_response_send (conn_info, &res_overlay, 
 				res_overlay.header.size);
 		}
 
-		totempg_groups_joined_release (reserved_msgs);
-		cs_conn_refcount_dec (conn);
+		api->sending_allowed_release (conn_info->sending_allowed_private_data);
+		coroipcs_refcount_dec (conn);
 	}
 	pthread_exit (0);
 }
@@ -396,9 +363,9 @@ req_setup_recv (
 	euid = -1;
 	egid = -1;
 	if (getpeereid(conn_info->fd, &euid, &egid) != -1 &&
-	    (euid == 0 || egid == g_gid_valid)) {
+	    (api->security_valid (euid, egid)) {
 		if (conn_info->state == CONN_IO_STATE_INITIALIZING) {
-			log_printf (LOG_LEVEL_SECURITY, "Connection not authenticated because gid is %d, expecting %d\n", egid, g_gid_valid);
+			api->log_printf ("Invalid security authentication\n");
 			return (-1);
 		}
 	}
@@ -414,16 +381,16 @@ req_setup_recv (
 	if (getpeerucred (conn_info->fd, &uc) == 0) {
 		euid = ucred_geteuid (uc);
 		egid = ucred_getegid (uc);
-		if ((euid == 0) || (egid == g_gid_valid)) {
+		if (api->security_valid (euid, egid) {
 			conn_info->authenticated = 1;
 		}
 		ucred_free(uc);
 	}
 	if (conn_info->authenticated == 0) {
-		log_printf (LOG_LEVEL_SECURITY, "Connection not authenticated because gid is %d, expecting %d\n", (int)egid, g_gid_valid);
+		api->log_printf ("Invalid security authentication\n");
  	}
 #else /* HAVE_GETPEERUCRED */
- 	log_printf (LOG_LEVEL_SECURITY, "Connection not authenticated "
+ 	api->log_printf (LOG_LEVEL_SECURITY, "Connection not authenticated "
  		"because platform does not support "
  		"authentication with sockets, continuing "
  		"with a fake authentication\n");
@@ -463,12 +430,10 @@ retry_recv:
 	assert (cmsg);
 	cred = (struct ucred *)CMSG_DATA (cmsg);
 	if (cred) {
-		if (cred->uid == 0 || cred->gid == g_gid_valid) {
+		if (api->security_valid (cred->uid, cred->gid)) {
 		} else {
 			ipc_disconnect (conn_info);
-			log_printf (LOG_LEVEL_SECURITY,
-				"Connection not authenticated because gid is %d, expecting %d\n",
-				cred->gid, g_gid_valid);
+			api->log_printf ("Invalid security authentication\n");
 			return (-1);
 		}
 	}
@@ -483,170 +448,6 @@ retry_recv:
 	return (0);
 }
 
-static int poll_handler_connection (
-	hdb_handle_t handle,
-	int fd,
-	int revent,
-	void *data)
-{
-	mar_req_setup_t *req_setup;
-	struct conn_info *conn_info = (struct conn_info *)data;
-	int res;
-	char buf;
-
-
-	if (ipc_thread_exiting (conn_info)) {
-		return conn_info_destroy (conn_info);
-	}
-
-	/*
-	 * If an error occurs, request exit
-	 */
-	if (revent & (POLLERR|POLLHUP)) {
-		ipc_disconnect (conn_info);
-		return (0);
-	}
-
-	/*
-	 * Read the header and process it
-	 */
-	if (conn_info->service == SOCKET_SERVICE_INIT && (revent & POLLIN)) {
-		/*
-		 * Receive in a nonblocking fashion the request
-		 * IF security invalid, send TRY_AGAIN, otherwise
-		 * send OK
-		 */
-		res = req_setup_recv (conn_info);
-		if (res == -1) {
-			req_setup_send (conn_info, CS_ERR_TRY_AGAIN);
-		}
-		if (res != 1) {
-			return (0);
-		}
-		req_setup_send (conn_info, CS_OK);
-
-		pthread_mutex_init (&conn_info->mutex, NULL);
-		req_setup = (mar_req_setup_t *)conn_info->setup_msg;
-		/*
-		 * Is the service registered ?
-		 */
-		if (!ais_service[req_setup->service]) {
-			ipc_disconnect (conn_info);
-			return (0);
-		}
-
-		conn_info->shmkey = req_setup->shmkey;
-		conn_info->semkey = req_setup->semkey;
-		conn_info->service = req_setup->service;
-		conn_info->refcount = 0;
-		conn_info->notify_flow_control_enabled = 0;
-		conn_info->setup_bytes_read = 0;
-
-		conn_info->shmid = shmget (conn_info->shmkey,
-			sizeof (struct shared_memory), 0600);
-		conn_info->mem = shmat (conn_info->shmid, NULL, 0);
-		conn_info->semid = semget (conn_info->semkey, 3, 0600);
-		conn_info->pending_semops = 0;
-
-		/*
-		 * ipc thread is the only reference at startup
-		 */
-		conn_info->refcount = 1; 
-		conn_info->state = CONN_STATE_THREAD_ACTIVE;
-
-		conn_info->private_data = malloc (ais_service[conn_info->service]->private_data_size);
-		memset (conn_info->private_data, 0,
-			ais_service[conn_info->service]->private_data_size);
-		ais_service[conn_info->service]->lib_init_fn (conn_info);
-
-
-		pthread_attr_init (&conn_info->thread_attr);
-		/*
-		* IA64 needs more stack space then other arches
-		*/
-		#if defined(__ia64__)
-		pthread_attr_setstacksize (&conn_info->thread_attr, 400000);
-		#else
-		pthread_attr_setstacksize (&conn_info->thread_attr, 200000);
-		#endif
-
-		pthread_attr_setdetachstate (&conn_info->thread_attr, PTHREAD_CREATE_JOINABLE);
-		res = pthread_create (&conn_info->thread,
-			&conn_info->thread_attr,
-			pthread_ipc_consumer,
-			conn_info);
-
-		/*
-		 * Security check - disallow multiple configurations of
-		 * the ipc connection
-		 */
-		if (conn_info->service == SOCKET_SERVICE_INIT) {
-			conn_info->service = -1;
-		}
-	} else
-	if (revent & POLLIN) {
-		cs_conn_refcount_inc (conn_info);
-		res = recv (fd, &buf, 1, MSG_NOSIGNAL);
-		if (res == 1) {
-			switch (buf) {
-			case MESSAGE_REQ_OUTQ_FLUSH:
-				outq_flush (conn_info);
-				break;
-			case MESSAGE_REQ_CHANGE_EUID:
-				if (priv_change (conn_info) == -1) {
-					ipc_disconnect (conn_info);
-				}
-				break;
-			default:
-				res = 0;
-				break;
-			}
-			cs_conn_refcount_dec (conn_info);
-		}
-#if defined(COROSYNC_SOLARIS) || defined(COROSYNC_BSD) || defined(COROSYNC_DARWIN)
-		/* On many OS poll never return POLLHUP or POLLERR.
-		 * EOF is detected when recvmsg return 0.
-		 */
-		if (res == 0) {
-			ipc_disconnect (conn_info);
-			return (0);
-		}
-#endif
-	}
-
-	cs_conn_refcount_inc (conn_info);
-	pthread_mutex_lock (&conn_info->mutex);
-	if ((conn_info->state == CONN_STATE_THREAD_ACTIVE) && (revent & POLLOUT)) {
-		buf = !list_empty (&conn_info->outq_head);
-		for (; conn_info->pending_semops;) {
-			res = send (conn_info->fd, &buf, 1, MSG_NOSIGNAL);
-			if (res == 1) {
-				conn_info->pending_semops--;
-			} else {
-				break;
-			}
-		}
-		if (conn_info->notify_flow_control_enabled) {
-			buf = 2;
-			res = send (conn_info->fd, &buf, 1, MSG_NOSIGNAL);
-			if (res == 1) {
-				conn_info->notify_flow_control_enabled = 0;
-			}
-		}
-		if (conn_info->notify_flow_control_enabled == 0 &&
-			conn_info->pending_semops == 0) {
-
-			poll_dispatch_modify (corosync_poll_handle,
-				conn_info->fd, POLLIN|POLLNVAL,
-				poll_handler_connection);
-		}
-	}
-	pthread_mutex_unlock (&conn_info->mutex);
-	cs_conn_refcount_dec (conn_info);
-
-	return (0);
-}
-
 static void ipc_disconnect (struct conn_info *conn_info)
 {
 	if (conn_info->state == CONN_STATE_THREAD_INACTIVE) {
@@ -667,7 +468,7 @@ static int conn_info_create (int fd)
 {
 	struct conn_info *conn_info;
 
-	conn_info = malloc (sizeof (struct conn_info));
+	conn_info = api->malloc (sizeof (struct conn_info));
 	if (conn_info == NULL) {
 		return (-1);
 	}
@@ -680,165 +481,74 @@ static int conn_info_create (int fd)
 	list_init (&conn_info->list);
 	list_add (&conn_info->list, &conn_info_list_head);
 
-        poll_dispatch_add (corosync_poll_handle, fd, POLLIN|POLLNVAL,
-		conn_info, poll_handler_connection);
+        api->poll_dispatch_add (fd, conn_info);
+
 	return (0);
 }
 
 #if defined(COROSYNC_LINUX) || defined(COROSYNC_SOLARIS)
 /* SUN_LEN is broken for abstract namespace
  */
-#define AIS_SUN_LEN(a) sizeof(*(a))
+#define COROSYNC_SUN_LEN(a) sizeof(*(a))
 #else
-#define AIS_SUN_LEN(a) SUN_LEN(a)
+#define COROSYNC_SUN_LEN(a) SUN_LEN(a)
 #endif
 
-#if defined(COROSYNC_LINUX)
-const char *socketname = "libais.socket";
-#else
-const char *socketname = SOCKETDIR "/libais.socket";
-#endif
-
-static int poll_handler_accept (
-	hdb_handle_t handle,
-	int fd,
-	int revent,
-	void *data)
-{
-	socklen_t addrlen;
-	struct sockaddr_un un_addr;
-	int new_fd;
-#ifdef COROSYNC_LINUX
-	int on = 1;
-#endif
-	int res;
-
-	addrlen = sizeof (struct sockaddr_un);
-
-retry_accept:
-	new_fd = accept (fd, (struct sockaddr *)&un_addr, &addrlen);
-	if (new_fd == -1 && errno == EINTR) {
-		goto retry_accept;
-	}
-
-	if (new_fd == -1) {
-		log_printf (LOG_LEVEL_ERROR, "ERROR: Could not accept Library connection: %s\n", strerror (errno));
-		return (0); /* This is an error, but -1 would indicate disconnect from poll loop */
-	}
 
-	totemip_nosigpipe(new_fd);
-	res = fcntl (new_fd, F_SETFL, O_NONBLOCK);
-	if (res == -1) {
-		log_printf (LOG_LEVEL_ERROR, "Could not set non-blocking operation on library connection: %s\n", strerror (errno));
-		close (new_fd);
-		return (0); /* This is an error, but -1 would indicate disconnect from poll loop */
-	}
-
-	/*
-	 * Valid accept
-	 */
-
-	/*
-	 * Request credentials of sender provided by kernel
-	 */
-#ifdef COROSYNC_LINUX
-	setsockopt(new_fd, SOL_SOCKET, SO_PASSCRED, &on, sizeof (on));
-#endif
-
-	log_printf (LOG_LEVEL_DEBUG, "connection received from libais client %d.\n", new_fd);
-
-	res = conn_info_create (new_fd);
-	if (res != 0) {
-		close (new_fd);
-	}
-
-	return (0);
-}
 /*
  * Exported functions
  */
-
-int message_source_is_local(mar_message_source_t *source)
+extern void coroipcs_ipc_init (
+        struct coroipcs_init_state *init_state)
 {
-	int ret = 0;
-
-	assert (source != NULL);
-	if (source->nodeid == totempg_my_nodeid_get ()) {
-		ret = 1;
-	}
-	return ret;
-}
-
-void message_source_set (
-	mar_message_source_t *source,
-	void *conn)
-{
-	assert ((source != NULL) && (conn != NULL));
-	memset (source, 0, sizeof (mar_message_source_t));
-	source->nodeid = totempg_my_nodeid_get ();
-	source->conn = conn;
-}
-
-void cs_ipc_init (
-	unsigned int gid_valid,
-	void (*serialize_lock_fn) (void),
-	void (*serialize_unlock_fn) (void))
-{
-	int libais_server_fd;
+	int server_fd;
 	struct sockaddr_un un_addr;
 	int res;
 
-	ipc_serialize_lock_fn = serialize_lock_fn;
-
-	ipc_serialize_unlock_fn = serialize_unlock_fn;
+	api = init_state;
 
 	/*
-	 * Create socket for libais clients, name socket, listen for connections
+	 * Create socket for IPC clients, name socket, listen for connections
 	 */
-	libais_server_fd = socket (PF_UNIX, SOCK_STREAM, 0);
-	if (libais_server_fd == -1) {
-		log_printf (LOG_LEVEL_ERROR ,"Cannot create libais client connections socket.\n");
-		corosync_exit_error (AIS_DONE_LIBAIS_SOCKET);
+	server_fd = socket (PF_UNIX, SOCK_STREAM, 0);
+	if (server_fd == -1) {
+		api->log_printf ("Cannot create client connections socket.\n");
+		api->fatal_error ("Can't create library listen socket");
 	};
 
-	totemip_nosigpipe (libais_server_fd);
-	res = fcntl (libais_server_fd, F_SETFL, O_NONBLOCK);
+	res = fcntl (server_fd, F_SETFL, O_NONBLOCK);
 	if (res == -1) {
-		log_printf (LOG_LEVEL_ERROR, "Could not set non-blocking operation on server socket: %s\n", strerror (errno));
-		corosync_exit_error (AIS_DONE_LIBAIS_SOCKET);
+		api->log_printf ("Could not set non-blocking operation on server socket: %s\n", strerror (errno));
+		api->fatal_error ("Could not set non-blocking operation on server socket");
 	}
 
-#if !defined(COROSYNC_LINUX)
-	unlink(socketname);
-#endif
 	memset (&un_addr, 0, sizeof (struct sockaddr_un));
 	un_addr.sun_family = AF_UNIX;
 #if defined(COROSYNC_BSD) || defined(COROSYNC_DARWIN)
 	un_addr.sun_len = sizeof(struct sockaddr_un);
 #endif
+
 #if defined(COROSYNC_LINUX)
-	strcpy (un_addr.sun_path + 1, socketname);
+	sprintf (un_addr.sun_path + 1, "%s", api->socket_name);
 #else
-	strcpy (un_addr.sun_path, socketname);
+	sprintf (un_addr.sun_path, "%s%s", SOCKETDIR, api->socket_name);
+	unlink (un_addr.sun_path);
 #endif
 
-	res = bind (libais_server_fd, (struct sockaddr *)&un_addr, AIS_SUN_LEN(&un_addr));
+	res = bind (server_fd, (struct sockaddr *)&un_addr, COROSYNC_SUN_LEN(&un_addr));
 	if (res) {
-		log_printf (LOG_LEVEL_ERROR, "ERROR: Could not bind AF_UNIX: %s.\n", strerror (errno));
-		corosync_exit_error (AIS_DONE_LIBAIS_BIND);
+		api->log_printf ("Could not bind AF_UNIX: %s.\n", strerror (errno));
+		api->fatal_error ("Could not bind to AF_UNIX socket\n");
 	}
-	listen (libais_server_fd, SERVER_BACKLOG);
+	listen (server_fd, SERVER_BACKLOG);
 
         /*
-         * Setup libais connection dispatch routine
+         * Setup connection dispatch routine
          */
-        poll_dispatch_add (corosync_poll_handle, libais_server_fd,
-                POLLIN|POLLNVAL, 0, poll_handler_accept);
-
-	g_gid_valid = gid_valid;
+        api->poll_accept_add (server_fd);
 }
 
-void cs_ipc_exit (void)
+void coroipcs_ipc_exit (void)
 {
 	struct list_head *list;
 	struct conn_info *conn_info;
@@ -859,14 +569,14 @@ void cs_ipc_exit (void)
 /*
  * Get the conn info private data
  */
-void *cs_conn_private_data_get (void *conn)
+void *coroipcs_private_data_get (void *conn)
 {
 	struct conn_info *conn_info = (struct conn_info *)conn;
 
 	return (conn_info->private_data);
 }
 
-int cs_response_send (void *conn, void *msg, int mlen)
+int coroipcs_response_send (void *conn, void *msg, int mlen)
 {
 	struct conn_info *conn_info = (struct conn_info *)conn;
 	struct sembuf sop;
@@ -888,7 +598,7 @@ retry_semop:
 	return (0);
 }
 
-int cs_response_iov_send (void *conn, struct iovec *iov, int iov_len)
+int coroipcs_response_iov_send (void *conn, struct iovec *iov, int iov_len)
 {
 	struct conn_info *conn_info = (struct conn_info *)conn;
 	struct sembuf sop;
@@ -976,8 +686,8 @@ static void msg_send (void *conn, struct iovec *iov, int iov_len, int locked)
 		if (locked == 0) {
 			pthread_mutex_unlock (&conn_info->mutex);
 		}
-        	poll_dispatch_modify (corosync_poll_handle, conn_info->fd,
-			POLLIN|POLLOUT|POLLNVAL, poll_handler_connection);
+		api->poll_dispatch_modify (conn_info->fd,
+			POLLIN|POLLOUT|POLLNVAL);
 	} else
 	if (res == -1) {
 		ipc_disconnect (conn_info);
@@ -1022,8 +732,8 @@ static void outq_flush (struct conn_info *conn_info) {
 			iov.iov_len = outq_item->mlen;
 			msg_send (conn_info, &iov, 1, MSG_SEND_UNLOCKED);
 			list_del (list);
-			free (iov.iov_base);
-			free (outq_item);
+			api->free (iov.iov_base);
+			api->free (outq_item);
 		} else {
 			break;
 		}
@@ -1096,14 +806,14 @@ static void msg_send_or_queue (void *conn, struct iovec *iov, int iov_len)
 		bytes_msg += iov[i].iov_len;
 	}
 	if (bytes_left < bytes_msg || list_empty (&conn_info->outq_head) == 0) {
-		outq_item = malloc (sizeof (struct outq_item));
+		outq_item = api->malloc (sizeof (struct outq_item));
 		if (outq_item == NULL) {
 			ipc_disconnect (conn);
 			return;
 		}
-		outq_item->msg = malloc (bytes_msg);
+		outq_item->msg = api->malloc (bytes_msg);
 		if (outq_item->msg == 0) {
-			free (outq_item);
+			api->free (outq_item);
 			ipc_disconnect (conn);
 			return;
 		}
@@ -1118,9 +828,8 @@ static void msg_send_or_queue (void *conn, struct iovec *iov, int iov_len)
 		pthread_mutex_lock (&conn_info->mutex);
 		if (list_empty (&conn_info->outq_head)) {
 			conn_info->notify_flow_control_enabled = 1;
-			poll_dispatch_modify (corosync_poll_handle,
-				conn_info->fd, POLLOUT|POLLIN|POLLNVAL,
-				poll_handler_connection);
+			api->poll_dispatch_modify (conn_info->fd,
+				POLLIN|POLLOUT|POLLNVAL);
 		}
 		list_add_tail (&outq_item->list, &conn_info->outq_head);
 		pthread_mutex_unlock (&conn_info->mutex);
@@ -1129,7 +838,7 @@ static void msg_send_or_queue (void *conn, struct iovec *iov, int iov_len)
 	msg_send (conn, iov, iov_len, MSG_SEND_LOCKED);
 }
 
-void cs_conn_refcount_inc (void *conn)
+void coroipcs_refcount_inc (void *conn)
 {
 	struct conn_info *conn_info = (struct conn_info *)conn;
 
@@ -1138,7 +847,7 @@ void cs_conn_refcount_inc (void *conn)
 	pthread_mutex_unlock (&conn_info->mutex);
 }
 
-void cs_conn_refcount_dec (void *conn)
+void coroipcs_refcount_dec (void *conn)
 {
 	struct conn_info *conn_info = (struct conn_info *)conn;
 
@@ -1147,7 +856,7 @@ void cs_conn_refcount_dec (void *conn)
 	pthread_mutex_unlock (&conn_info->mutex);
 }
 
-int cs_dispatch_send (void *conn, void *msg, int mlen)
+int coroipcs_dispatch_send (void *conn, void *msg, int mlen)
 {
 	struct iovec iov;
 
@@ -1158,8 +867,223 @@ int cs_dispatch_send (void *conn, void *msg, int mlen)
 	return (0);
 }
 
-int cs_dispatch_iov_send (void *conn, struct iovec *iov, int iov_len)
+int coroipcs_dispatch_iov_send (void *conn, struct iovec *iov, int iov_len)
 {
 	msg_send_or_queue (conn, iov, iov_len);
 	return (0);
 }
+
+int coroipcs_handler_accept (
+	int fd,
+	int revent,
+	void *data)
+{
+	socklen_t addrlen;
+	struct sockaddr_un un_addr;
+	int new_fd;
+#ifdef COROSYNC_LINUX
+	int on = 1;
+#endif
+	int res;
+
+	addrlen = sizeof (struct sockaddr_un);
+
+retry_accept:
+	new_fd = accept (fd, (struct sockaddr *)&un_addr, &addrlen);
+	if (new_fd == -1 && errno == EINTR) {
+		goto retry_accept;
+	}
+
+	if (new_fd == -1) {
+		api->log_printf ("Could not accept Library connection: %s\n", strerror (errno));
+		return (0); /* This is an error, but -1 would indicate disconnect from poll loop */
+	}
+
+	res = fcntl (new_fd, F_SETFL, O_NONBLOCK);
+	if (res == -1) {
+		api->log_printf ("Could not set non-blocking operation on library connection: %s\n", strerror (errno));
+		close (new_fd);
+		return (0); /* This is an error, but -1 would indicate disconnect from poll loop */
+	}
+
+	/*
+	 * Valid accept
+	 */
+
+	/*
+	 * Request credentials of sender provided by kernel
+	 */
+#ifdef COROSYNC_LINUX
+	setsockopt(new_fd, SOL_SOCKET, SO_PASSCRED, &on, sizeof (on));
+#endif
+
+	res = conn_info_create (new_fd);
+	if (res != 0) {
+		close (new_fd);
+	}
+
+	return (0);
+}
+
+int coroipcs_handler_dispatch (
+	int fd,
+	int revent,
+	void *context)
+{
+	mar_req_setup_t *req_setup;
+	struct conn_info *conn_info = (struct conn_info *)context;
+	int res;
+	char buf;
+
+
+	if (ipc_thread_exiting (conn_info)) {
+		return conn_info_destroy (conn_info);
+	}
+
+	/*
+	 * If an error occurs, request exit
+	 */
+	if (revent & (POLLERR|POLLHUP)) {
+		ipc_disconnect (conn_info);
+		return (0);
+	}
+
+	/*
+	 * Read the header and process it
+	 */
+	if (conn_info->service == SOCKET_SERVICE_INIT && (revent & POLLIN)) {
+		/*
+		 * Receive in a nonblocking fashion the request
+		 * IF security invalid, send TRY_AGAIN, otherwise
+		 * send OK
+		 */
+		res = req_setup_recv (conn_info);
+		if (res == -1) {
+			req_setup_send (conn_info, CS_ERR_TRY_AGAIN);
+		}
+		if (res != 1) {
+			return (0);
+		}
+		req_setup_send (conn_info, CS_OK);
+
+		pthread_mutex_init (&conn_info->mutex, NULL);
+		req_setup = (mar_req_setup_t *)conn_info->setup_msg;
+		/*
+		 * Is the service registered ?
+		 */
+		if (api->service_available (req_setup->service) == 0) {
+			ipc_disconnect (conn_info);
+			return (0);
+		}
+
+		conn_info->shmkey = req_setup->shmkey;
+		conn_info->semkey = req_setup->semkey;
+		conn_info->service = req_setup->service;
+		conn_info->refcount = 0;
+		conn_info->notify_flow_control_enabled = 0;
+		conn_info->setup_bytes_read = 0;
+
+		conn_info->shmid = shmget (conn_info->shmkey,
+			sizeof (struct shared_memory), 0600);
+		conn_info->mem = shmat (conn_info->shmid, NULL, 0);
+		conn_info->semid = semget (conn_info->semkey, 3, 0600);
+		conn_info->pending_semops = 0;
+
+		/*
+		 * ipc thread is the only reference at startup
+		 */
+		conn_info->refcount = 1; 
+		conn_info->state = CONN_STATE_THREAD_ACTIVE;
+
+		conn_info->private_data = api->malloc (api->private_data_size_get (conn_info->service));
+		memset (conn_info->private_data, 0,
+			api->private_data_size_get (conn_info->service));
+
+		api->init_fn_get (conn_info->service) (conn_info);
+
+		pthread_attr_init (&conn_info->thread_attr);
+		/*
+		* IA64 needs more stack space then other arches
+		*/
+		#if defined(__ia64__)
+		pthread_attr_setstacksize (&conn_info->thread_attr, 400000);
+		#else
+		pthread_attr_setstacksize (&conn_info->thread_attr, 200000);
+		#endif
+
+		pthread_attr_setdetachstate (&conn_info->thread_attr, PTHREAD_CREATE_JOINABLE);
+		res = pthread_create (&conn_info->thread,
+			&conn_info->thread_attr,
+			pthread_ipc_consumer,
+			conn_info);
+
+		/*
+		 * Security check - disallow multiple configurations of
+		 * the ipc connection
+		 */
+		if (conn_info->service == SOCKET_SERVICE_INIT) {
+			conn_info->service = -1;
+		}
+	} else
+	if (revent & POLLIN) {
+		coroipcs_refcount_inc (conn_info);
+		res = recv (fd, &buf, 1, MSG_NOSIGNAL);
+		if (res == 1) {
+			switch (buf) {
+			case MESSAGE_REQ_OUTQ_FLUSH:
+				outq_flush (conn_info);
+				break;
+			case MESSAGE_REQ_CHANGE_EUID:
+				if (priv_change (conn_info) == -1) {
+					ipc_disconnect (conn_info);
+				}
+				break;
+			default:
+				res = 0;
+				break;
+			}
+			coroipcs_refcount_dec (conn_info);
+		}
+#if defined(COROSYNC_SOLARIS) || defined(COROSYNC_BSD) || defined(COROSYNC_DARWIN)
+		/* On many OS poll never return POLLHUP or POLLERR.
+		 * EOF is detected when recvmsg return 0.
+		 */
+		if (res == 0) {
+			ipc_disconnect (conn_info);
+			return (0);
+		}
+#endif
+	}
+
+	coroipcs_refcount_inc (conn_info);
+	pthread_mutex_lock (&conn_info->mutex);
+	if ((conn_info->state == CONN_STATE_THREAD_ACTIVE) && (revent & POLLOUT)) {
+		buf = !list_empty (&conn_info->outq_head);
+		for (; conn_info->pending_semops;) {
+			res = send (conn_info->fd, &buf, 1, MSG_NOSIGNAL);
+			if (res == 1) {
+				conn_info->pending_semops--;
+			} else {
+				break;
+			}
+		}
+		if (conn_info->notify_flow_control_enabled) {
+			buf = 2;
+			res = send (conn_info->fd, &buf, 1, MSG_NOSIGNAL);
+			if (res == 1) {
+				conn_info->notify_flow_control_enabled = 0;
+			}
+		}
+		if (conn_info->notify_flow_control_enabled == 0 &&
+			conn_info->pending_semops == 0) {
+
+			api->poll_dispatch_modify (conn_info->fd,
+				POLLIN|POLLNVAL);
+		}
+	}
+	pthread_mutex_unlock (&conn_info->mutex);
+	coroipcs_refcount_dec (conn_info);
+
+	return (0);
+}
+

+ 95 - 0
exec/coroipcs.h

@@ -0,0 +1,95 @@
+/*
+ * 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>
+
+#define SOCKET_SERVICE_INIT 0xFFFFFFFF
+
+typedef int (*coroipcs_init_fn_lvalue) (void *conn);
+typedef int (*coroipcs_exit_fn_lvalue) (void *conn);
+typedef void (*coroipcs_handler_fn_lvalue) (void *conn, void *msg);
+
+struct coroipcs_init_state {
+	const char *socket_name;
+	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 (*response_size_get)(unsigned int service, unsigned int id);
+	int (*response_id_get)(unsigned int service, unsigned int id);
+	int (*sending_allowed)(unsigned int service, unsigned int id,
+		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 (*fatal_error)(const char *error_msg);
+	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);
+};
+
+extern void coroipcs_ipc_init (
+	struct coroipcs_init_state *init_state);
+
+extern void *coroipcs_private_data_get (void *conn);
+
+extern int coroipcs_response_send (void *conn, void *msg, int mlen);
+
+extern int coroipcs_response_iov_send (void *conn, struct iovec *iov, int iov_len);
+
+extern int coroipcs_dispatch_send (void *conn, void *msg, int mlen);
+
+extern int coroipcs_dispatch_iov_send (void *conn, struct iovec *iov, 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_handler_accept (int fd, int revent, void *context);
+
+extern int coroipcs_handler_dispatch (int fd, int revent, void *context);
+
+#endif /* COROIPCS_H_DEFINED */

+ 1 - 11
exec/coropoll.c

@@ -60,8 +60,6 @@ struct poll_instance {
 	struct pollfd *ufds;
 	int poll_entry_count;
 	struct timerlist timerlist;
-	void (*serialize_lock_fn) (void);
-	void (*serialize_unlock_fn) (void);
 	int stop_requested;
 };
 
@@ -74,9 +72,7 @@ static struct hdb_handle_database poll_instance_database = {
 	.iterator	= 0
 };
 
-hdb_handle_t poll_create (
-	void (*serialize_lock_fn) (void),
-	void (*serialize_unlock_fn) (void))
+hdb_handle_t poll_create (void)
 {
 	hdb_handle_t handle;
 	struct poll_instance *poll_instance;
@@ -97,8 +93,6 @@ hdb_handle_t poll_create (
 	poll_instance->ufds = 0;
 	poll_instance->poll_entry_count = 0;
 	poll_instance->stop_requested = 0;
-	poll_instance->serialize_lock_fn = serialize_lock_fn;
-	poll_instance->serialize_unlock_fn = serialize_unlock_fn;
 	timerlist_init (&poll_instance->timerlist);
 
 	return (handle);
@@ -408,13 +402,11 @@ retry_poll:
 			if (poll_instance->ufds[i].fd != -1 &&
 				poll_instance->ufds[i].revents) {
 
-				poll_instance->serialize_lock_fn();
 				res = poll_instance->poll_entries[i].dispatch_fn (handle,
 					poll_instance->ufds[i].fd, 
 					poll_instance->ufds[i].revents,
 					poll_instance->poll_entries[i].data);
 
-				poll_instance->serialize_unlock_fn();
 				/*
 				 * Remove dispatch functions that return -1
 				 */
@@ -423,9 +415,7 @@ retry_poll:
 				}
 			}
 		}
-		poll_instance->serialize_lock_fn();
 		timerlist_expire (&poll_instance->timerlist);
-		poll_instance->serialize_unlock_fn();
 	} /* for (;;) */
 
 	hdb_handle_put (&poll_instance_database, handle);

+ 0 - 64
exec/ipc.h

@@ -1,64 +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 IPC_H_DEFINED
-#define IPC_H_DEFINED
-
-extern void message_source_set (mar_message_source_t *source, void *conn);
-
-extern int message_source_is_local (mar_message_source_t *source);
-
-extern void cs_ipc_init (
-	unsigned int gid_valid,
-        void (*serialize_lock_fn) (void),
-        void (*serialize_unlock_fn) (void)
-);
-
-extern void *cs_conn_private_data_get (void *conn);
-
-extern int cs_response_send (void *conn, void *msg, int mlen);
-
-extern int cs_response_iov_send (void *conn, struct iovec *iov, int iov_len);
-
-extern int cs_dispatch_send (void *conn, void *msg, int mlen);
-
-extern int cs_dispatch_iov_send (void *conn, struct iovec *iov, int iov_len);
-
-extern void cs_conn_refcount_inc (void *conn);
-
-extern void cs_conn_refcount_dec (void *conn);
-
-extern void cs_ipc_exit (void);
-
-#endif /* IPC_H_DEFINED */

+ 237 - 18
exec/main.c

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2002-2006 MontaVista Software, Inc.
- * Copyright (c) 2006-2008 Red Hat, Inc.
+ * Copyright (c) 2006-2009 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -75,7 +75,7 @@
 #include "main.h"
 #include "sync.h"
 #include "tlist.h"
-#include "ipc.h"
+#include "coroipcs.h"
 #include "timer.h"
 #include "util.h"
 #include "apidef.h"
@@ -95,7 +95,11 @@ LOGSYS_DECLARE_SUBSYS ("MAIN", LOG_INFO);
 
 static unsigned int service_count = 32;
 
+#if defined(HAVE_PTHREAD_SPIN_LOCK)
+static pthread_spinlock_t serialize_spin;
+#else
 static pthread_mutex_t serialize_mutex = PTHREAD_MUTEX_INITIALIZER;
+#endif
 
 static struct totem_logging_configuration totem_logging_configuration;
 
@@ -109,6 +113,8 @@ static struct objdb_iface_ver0 *objdb = NULL;
 
 static struct corosync_api_v1 *api = NULL;
 
+static struct main_config main_config;
+
 unsigned long long *(*main_clm_get_by_nodeid) (unsigned int node_id);
 
 hdb_handle_t corosync_poll_handle;
@@ -146,7 +152,7 @@ static void *corosync_exit (void *arg)
 
 	poll_stop (0);
 	totempg_finalize ();
-	cs_ipc_exit ();
+	coroipcs_ipc_exit ();
 	corosync_exit_error (AIS_DONE_EXIT);
 
 	/* never reached */
@@ -203,15 +209,28 @@ static int pool_sizes[] = { 0, 0, 0, 0, 0, 4096, 0, 1, 0, /* 256 */
 					1024, 0, 1, 4096, 0, 0, 0, 0, /* 65536 */
 					1, 1, 1, 1, 1, 1, 1, 1, 1 };
 
-void serialize_mutex_lock (void)
+#if defined(HAVE_PTHREAD_SPIN_LOCK)
+void serialize_lock (void)
+{
+	pthread_spin_lock (&serialize_spin);
+}
+
+void serialize_unlock (void)
+{
+	pthread_spin_unlock (&serialize_spin);
+}
+#else
+void serialize_lock (void)
 {
 	pthread_mutex_lock (&serialize_mutex);
 }
 
-void serialize_mutex_unlock (void)
+void serialize_unlock (void)
 {
 	pthread_mutex_unlock (&serialize_mutex);
 }
+#endif
+
 
 
 static void corosync_sync_completed (void)
@@ -258,6 +277,7 @@ static void confchg_fn (
 {
 	int i;
 
+	serialize_lock ();
 	memcpy (&corosync_ring_id, ring_id, sizeof (struct memb_ring_id));
 
 	/*
@@ -271,13 +291,14 @@ static void confchg_fn (
 				joined_list, joined_list_entries, ring_id);
 		}
 	}
+	serialize_unlock ();
 }
 
-static void priv_drop (struct main_config *main_config)
+static void priv_drop (void)
 {
 return; /* TODO: we are still not dropping privs */
-	setuid (main_config->uid);
-	setegid (main_config->gid);
+	setuid (main_config.uid);
+	setegid (main_config.gid);
 }
 
 static void corosync_mempool_init (void)
@@ -427,6 +448,9 @@ static void deliver_fn (
 	fn_id = header->id & 0xffff;
 	if (!ais_service[service])
 		return;
+
+	serialize_lock();
+
 	if (endian_conversion_required) {
 		assert(ais_service[service]->exec_engine[fn_id].exec_endian_convert_fn != NULL);
 		ais_service[service]->exec_engine[fn_id].exec_endian_convert_fn
@@ -435,6 +459,8 @@ static void deliver_fn (
 
 	ais_service[service]->exec_engine[fn_id].exec_handler_fn
 		(header, nodeid);
+
+	serialize_unlock();
 }
 
 void main_get_config_modules(struct config_iface_ver0 ***modules, int *num)
@@ -451,10 +477,201 @@ int main_mcast (
 	return (totempg_groups_mcast_joined (corosync_group_handle, iovec, iov_len, guarantee));
 }
 
+int message_source_is_local (mar_message_source_t *source)
+{
+	int ret = 0;
+
+	assert (source != NULL);
+	if (source->nodeid == totempg_my_nodeid_get ()) {
+		ret = 1;
+	}
+	return ret;
+}
+
+void message_source_set (
+	mar_message_source_t *source,
+	void *conn)
+{
+	assert ((source != NULL) && (conn != NULL));
+	memset (source, 0, sizeof (mar_message_source_t));
+	source->nodeid = totempg_my_nodeid_get ();
+	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)
+{
+	if (euid == 0 || egid == 0) {
+		return (1);
+	}
+	if (euid == main_config.uid || egid == main_config.gid) {
+		return (1);
+	}
+	return (0);
+}
+
+static int corosync_service_available (unsigned int service)
+{
+	return (ais_service[service]);
+}
+
+static int corosync_response_size_get (unsigned int service, unsigned int id)
+{
+	return (ais_service[service]->lib_engine[id].response_size);
+
+}
+
+static int corosync_response_id_get (unsigned int service, unsigned int id)
+{
+	return (ais_service[service]->lib_engine[id].response_id);
+}
+
+
+struct sending_allowed_private_data_struct {
+	int reserved_msgs;
+};
+
+static int corosync_sending_allowed (
+	unsigned int service,
+	unsigned int id, 
+	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;
+	mar_req_header_t *header = (mar_req_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);
+
+	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;
+
+	totempg_groups_joined_release (pd->reserved_msgs);
+}
+
+static int ipc_subsys_id = -1;
+
+static void ipc_log_printf (char *format, ...) {
+        va_list ap;
+
+        va_start (ap, format);
+	
+       _logsys_log_printf (ipc_subsys_id, __FUNCTION__,	
+                __FILE__, __LINE__, LOG_LEVEL_ERROR, format, ap);
+
+        va_end (ap);
+}
+
+static int corosync_poll_handler_accept (
+	hdb_handle_t handle,	
+	int fd,
+	int revent,
+	void *context)
+{
+	return (coroipcs_handler_accept (fd, revent, context));
+}
+
+static int corosync_poll_handler_dispatch (
+	hdb_handle_t handle,	
+	int fd,
+	int revent,
+	void *context)
+{
+	return (coroipcs_handler_dispatch (fd, revent, context));
+}
+
+
+static void corosync_poll_accept_add (
+	int fd)
+{
+	poll_dispatch_add (corosync_poll_handle, fd, POLLIN|POLLNVAL, 0,
+		corosync_poll_handler_accept);
+}
+
+static void corosync_poll_dispatch_add (
+	int fd,
+	void *context)
+{
+	poll_dispatch_add (corosync_poll_handle, fd, POLLIN|POLLNVAL, context,
+		corosync_poll_handler_dispatch);
+}
+
+static void corosync_poll_dispatch_modify (
+	int fd,
+	int events)
+{
+	poll_dispatch_modify (corosync_poll_handle, fd, events,
+		corosync_poll_handler_dispatch);
+}
+
+struct coroipcs_init_state ipc_init_state = {
+	.socket_name			= IPC_SOCKET_NAME,
+	.malloc				= malloc,
+	.free				= free,
+	.log_printf			= ipc_log_printf,
+	.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,
+	.response_size_get		= corosync_response_size_get,
+	.response_id_get		= corosync_response_id_get,
+	.poll_accept_add		= corosync_poll_accept_add,
+	.poll_dispatch_add		= corosync_poll_dispatch_add,
+	.poll_dispatch_modify		= corosync_poll_dispatch_modify,
+	.init_fn_get			= corosync_init_fn_get,
+	.exit_fn_get			= corosync_exit_fn_get,
+	.handler_fn_get			= corosync_handler_fn_get
+};
+
 int main (int argc, char **argv)
 {
 	const char *error_string;
-	struct main_config main_config;
 	struct totem_config totem_config;
 	hdb_handle_t objdb_handle;
 	hdb_handle_t config_handle;
@@ -467,6 +684,10 @@ int main (int argc, char **argv)
 	int res, ch;
 	int background, setprio;
 
+#if defined(HAVE_PTHREAD_SPIN_LOCK)
+	pthread_spin_init (&serialize_spin, 0);
+#endif
+
  	/* default configuration
 	 */
 	background = 1;
@@ -505,14 +726,12 @@ int main (int argc, char **argv)
 	(void)signal (SIGQUIT, sigquit_handler);
 	
 	corosync_timer_init (
-		serialize_mutex_lock,
-		serialize_mutex_unlock);
+		serialize_lock,
+		serialize_unlock);
 
 	log_printf (LOG_LEVEL_NOTICE, "Corosync Executive Service: started and ready to provide service.\n");
 
-	corosync_poll_handle = poll_create (
-		serialize_mutex_lock,
-		serialize_mutex_unlock);
+	corosync_poll_handle = poll_create ();
 
 	/*
 	 * Load the object database interface
@@ -678,13 +897,13 @@ int main (int argc, char **argv)
 	 * CAP_SYS_NICE (setscheduler)
 	 * CAP_IPC_LOCK (mlockall)
 	 */
-	priv_drop (&main_config);
+	priv_drop ();
 
 	corosync_mempool_init ();
 
-	cs_ipc_init (main_config.gid,
-		serialize_mutex_lock,
-		serialize_mutex_unlock);
+	ipc_subsys_id = _logsys_subsys_create ("IPC", LOG_INFO);
+
+	coroipcs_ipc_init (&ipc_init_state);
 
 	/*
 	 * Start main processing loop

+ 5 - 3
exec/main.h

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2002-2006 MontaVista Software, Inc.
- * Copyright (c) 2006-2007 Red Hat, Inc.
+ * Copyright (c) 2006-2009 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -45,8 +45,6 @@
 #include <corosync/engine/objdb.h>
 #include <corosync/engine/config.h>
 
-#define SOCKET_SERVICE_INIT 254
-
 extern struct totempg_group corosync_group;
 
 extern hdb_handle_t corosync_group_handle;
@@ -62,4 +60,8 @@ extern int main_mcast (
 	int iov_len,
 	unsigned int guarantee);
 
+extern void message_source_set (mar_message_source_t *source, void *conn);
+
+extern int message_source_is_local (mar_message_source_t *source);
+
 #endif /* MAIN_H_DEFINED */

+ 1 - 1
exec/service.c

@@ -51,7 +51,7 @@
 #include <corosync/totem/totempg.h>
 #include <corosync/totem/totemip.h>
 #include "main.h"
-#include "ipc.h"
+#include "coroipcs.h"
 #include <corosync/engine/coroapi.h>
 #include "service.h"
 

+ 1 - 1
include/Makefile.am

@@ -32,7 +32,7 @@
 MAINTAINERCLEANFILES    = Makefile.in corosync/config.h.in
 
 CS_H			= hdb.h cs_config.h cpg.h cfg.h evs.h ipc_gen.h mar_gen.h swab.h 	\
-		  	coroipc.h confdb.h list.h corotypes.h quorum.h votequorum.h
+		  	coroipcc.h confdb.h list.h corotypes.h quorum.h votequorum.h
 
 CS_INTERNAL_H		= ipc_cfg.h ipc_confdb.h ipc_cpg.h ipc_evs.h ipc_pload.h ipc_quorum.h 	\
 			jhash.h mar_cpg.h pload.h queue.h quorum.h rmd.h sq.h ipc_votequorum.h

+ 8 - 7
include/corosync/coroipc.h → include/corosync/coroipcc.h

@@ -68,30 +68,31 @@ struct saHandleDatabase {
 
 
 cs_error_t
-cslib_service_connect (
+coroipcc_service_connect (
+	const char *socket_name,
 	enum service_types service,
 	void **ipc_context);
 
 cs_error_t
-cslib_service_disconnect (
+coroipcc_service_disconnect (
 	void *ipc_context);
 
 int
-cslib_fd_get (
+coroipcc_fd_get (
 	void *ipc_context);
 
 int
-cslib_dispatch_recv (
+coroipcc_dispatch_recv (
 	void *ipc_context,
 	void *buf,
 	int timeout);
 
 int
-cslib_dispatch_flow_control_get (
+coroipcc_dispatch_flow_control_get (
 	void *ipc_context);
 
 cs_error_t
-cslib_msg_send_reply_receive (
+coroipcc_msg_send_reply_receive (
 	void *ipc_context,
 	struct iovec *iov,
 	int iov_len,
@@ -99,7 +100,7 @@ cslib_msg_send_reply_receive (
 	int res_len);
 
 cs_error_t
-cslib_msg_send_reply_receive_in_buf (
+coroipcc_msg_send_reply_receive_in_buf (
 	void *ipc_context,
 	struct iovec *iov,
 	int iov_len,

+ 2 - 0
include/corosync/ipc_gen.h

@@ -54,6 +54,8 @@ enum service_types {
 	VOTEQUORUM_SERVICE = 14,
 };
 
+#define IPC_SOCKET_NAME "corosync.ipc"
+
 enum req_init_types {
 	MESSAGE_REQ_RESPONSE_INIT = 0,
 	MESSAGE_REQ_DISPATCH_INIT = 1

+ 1 - 3
include/corosync/totem/coropoll.h

@@ -39,9 +39,7 @@
 
 typedef void * poll_timer_handle;
 
-hdb_handle_t poll_create (
-	void (*serialize_lock) (void),
-	void (*serialize_unlock) (void));
+hdb_handle_t poll_create (void);
 
 int poll_destroy (hdb_handle_t hdb_handle_t);
 

+ 22 - 22
lib/Makefile.am

@@ -37,23 +37,23 @@ AM_CFLAGS		= -fPIC
 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 libcoroipc.a
+			  libvotequorum.a libpload.a libcoroipcc.a
 SHARED_LIBS		= $(lib_LIBRARIES:%.a=%.so.$(SONAME))
 SHARED_LIBS_SO		= $(lib_LIBRARIES:%.a=%.so)
 SHARED_LIBS_SO_TWO	= $(lib_LIBRARIES:%.a=%.so.$(SOMAJOR))
 
-libcpg_a_SOURCES	= coroipc.c cpg.c
-libcfg_a_SOURCES	= coroipc.c cfg.c
-libevs_a_SOURCES	= coroipc.c evs.c
-libpload_a_SOURCES	= coroipc.c pload.c
-libquorum_a_SOURCES	= coroipc.c quorum.c
-libvotequorum_a_SOURCES	= coroipc.c votequorum.c
-libconfdb_a_SOURCES	= coroipc.c confdb.c sa-confdb.c
-libcoroipc_a_SOURCES	= coroipc.c
+libcpg_a_SOURCES	= coroipcc.c cpg.c
+libcfg_a_SOURCES	= coroipcc.c cfg.c
+libevs_a_SOURCES	= coroipcc.c evs.c
+libpload_a_SOURCES	= coroipcc.c pload.c
+libquorum_a_SOURCES	= coroipcc.c quorum.c
+libvotequorum_a_SOURCES	= coroipcc.c votequorum.c
+libconfdb_a_SOURCES	= coroipcc.c confdb.c sa-confdb.c
+libcoroipcc_a_SOURCES	= coroipcc.c
 
 noinst_HEADERS		= sa-confdb.h util.h \
 			  libcfg.versions libconfdb.versions \
-			  libcoroipc.versions libcpg.versions \
+			  libcoroipcc.versions libcpg.versions \
 			  libevs.versions libpload.versions \
 			  libquorum.versions libvotequorum.versions
 
@@ -62,26 +62,26 @@ noinst_HEADERS		= sa-confdb.h util.h \
 
 if BUILD_DARWIN
 
-libcoroipc.so.$(SONAME): coroipc.o
-	$(CC) $(LDFLAGS) $(DARWIN_OPTS) coroipc.o -o $@
+libcoroipcc.so.$(SONAME): coroipcc.o
+	$(CC) $(LDFLAGS) $(DARWIN_OPTS) coroipcc.o -o $@
 
-libconfdb.so.$(SONAME): coroipc.o confdb.o sa-confdb.o 
-	$(CC) $(LDFLAGS) $(DARWIN_OPTS) coroipc.o confdb.o sa-confdb.o ../lcr/lcr_ifact.o -o $@ -ldl
+libconfdb.so.$(SONAME): coroipcc.o confdb.o sa-confdb.o 
+	$(CC) $(LDFLAGS) $(DARWIN_OPTS) coroipcc.o confdb.o sa-confdb.o ../lcr/lcr_ifact.o -o $@ -ldl
 
-lib%.so.$(SONAME): coroipc.o %.o
+lib%.so.$(SONAME): coroipcc.o %.o
 	$(CC) $(DARWIN_OPTS) $^ -o $@
 
 else
 
-libcoroipc.so.$(SONAME): coroipc.o
+libcoroipcc.so.$(SONAME): coroipcc.o
 	$(CC) -shared -o $@ \
-		-Wl,-soname=libcoroipc.so.$(SOMAJOR) \
-		-Wl,-version-script=$(srcdir)/libcoroipc.versions \
+		-Wl,-soname=libcoroipcc.so.$(SOMAJOR) \
+		-Wl,-version-script=$(srcdir)/libcoroipcc.versions \
 		$^ $(LDFLAGS) $(AM_LDFLAGS)
-	ln -sf libcoroipc.so.$(SONAME) libcoroipc.so
-	ln -sf libcoroipc.so.$(SONAME) libcoroipc.so.$(SOMAJOR)
+	ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so
+	ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so.$(SOMAJOR)
 
-libconfdb.so.$(SONAME): coroipc.o confdb.o sa-confdb.o ../lcr/lcr_ifact.o
+libconfdb.so.$(SONAME): coroipcc.o confdb.o sa-confdb.o ../lcr/lcr_ifact.o
 	$(CC) -shared -o $@ \
 		-Wl,-soname=libconfdb.so.$(SOMAJOR) \
 		-Wl,-version-script=$(srcdir)/libconfdb.versions \
@@ -89,7 +89,7 @@ libconfdb.so.$(SONAME): coroipc.o confdb.o sa-confdb.o ../lcr/lcr_ifact.o
 	ln -sf libconfdb.so.$(SONAME) libconfdb.so
 	ln -sf libconfdb.so.$(SONAME) libconfdb.so.$(SOMAJOR)
 
-lib%.so.$(SONAME): coroipc.o %.o
+lib%.so.$(SONAME): coroipcc.o %.o
 	$(CC) -shared -o $@ \
 		-Wl,-soname=lib$*.so.$(SOMAJOR) \
 		-Wl,-version-script=$(srcdir)/lib$*.versions \

+ 18 - 18
lib/cfg.c

@@ -54,7 +54,7 @@
 #include <corosync/mar_gen.h>
 #include <corosync/ipc_gen.h>
 #include <corosync/ipc_cfg.h>
-#include <corosync/coroipc.h>
+#include <corosync/coroipcc.h>
 
 struct cfg_res_overlay {
 	mar_res_header_t header;
@@ -115,7 +115,7 @@ corosync_cfg_initialize (
 		goto error_destroy;
 	}
 
-	error = cslib_service_connect (CFG_SERVICE, &cfg_instance->ipc_ctx);
+	error = coroipcc_service_connect (IPC_SOCKET_NAME, CFG_SERVICE, &cfg_instance->ipc_ctx);
 	if (error != CS_OK) {
 		goto error_put_destroy;
 	}
@@ -153,7 +153,7 @@ corosync_cfg_fd_get (
 		return (error);
 	}
 
-	*selection_fd = cslib_fd_get (cfg_instance->ipc_ctx);
+	*selection_fd = coroipcc_fd_get (cfg_instance->ipc_ctx);
 
 	(void)saHandleInstancePut (&cfg_hdb, cfg_handle);
 	return (CS_OK);
@@ -194,7 +194,7 @@ corosync_cfg_dispatch (
 	}
 
 	do {
-		dispatch_avail = cslib_dispatch_recv (cfg_instance->ipc_ctx,
+		dispatch_avail = coroipcc_dispatch_recv (cfg_instance->ipc_ctx,
 			(void *)&dispatch_data, timeout);
 
 		/*
@@ -287,7 +287,7 @@ corosync_cfg_finalize (
 
 	cfg_instance->finalize = 1;
 
-	cslib_service_disconnect (cfg_instance->ipc_ctx);
+	coroipcc_service_disconnect (cfg_instance->ipc_ctx);
 
 	pthread_mutex_unlock (&cfg_instance->response_mutex);
 
@@ -331,7 +331,7 @@ corosync_cfg_ring_status_get (
 
 	pthread_mutex_lock (&cfg_instance->response_mutex);
 
-	error = cslib_msg_send_reply_receive(cfg_instance->ipc_ctx,
+	error = coroipcc_msg_send_reply_receive(cfg_instance->ipc_ctx,
 		&iov,
 		1,
 		&res_lib_cfg_ringstatusget,
@@ -411,7 +411,7 @@ corosync_cfg_ring_reenable (
 
 	pthread_mutex_lock (&cfg_instance->response_mutex);
 
-	error = cslib_msg_send_reply_receive (cfg_instance->ipc_ctx,
+	error = coroipcc_msg_send_reply_receive (cfg_instance->ipc_ctx,
 		&iov,
 		1,
 		&res_lib_cfg_ringreenable,
@@ -453,7 +453,7 @@ corosync_cfg_service_load (
 
 	pthread_mutex_lock (&cfg_instance->response_mutex);
 
-	error = cslib_msg_send_reply_receive (cfg_instance->ipc_ctx,
+	error = coroipcc_msg_send_reply_receive (cfg_instance->ipc_ctx,
 		&iov,
 		1,
 		&res_lib_cfg_serviceload,
@@ -495,7 +495,7 @@ corosync_cfg_service_unload (
 
 	pthread_mutex_lock (&cfg_instance->response_mutex);
 
-	error = cslib_msg_send_reply_receive (cfg_instance->ipc_ctx,
+	error = coroipcc_msg_send_reply_receive (cfg_instance->ipc_ctx,
 		&iov,
 		1,
 		&res_lib_cfg_serviceunload,
@@ -534,7 +534,7 @@ corosync_cfg_state_track (
 
 	pthread_mutex_lock (&cfg_instance->response_mutex);
 
-	error = cslib_msg_send_reply_receive (cfg_instance->ipc_ctx,
+	error = coroipcc_msg_send_reply_receive (cfg_instance->ipc_ctx,
 		&iov,
 		1,
 		&res_lib_cfg_statetrack,
@@ -570,7 +570,7 @@ corosync_cfg_state_track_stop (
 	iov.iov_len = sizeof (struct req_lib_cfg_statetrackstop),
 	pthread_mutex_lock (&cfg_instance->response_mutex);
 
-	error = cslib_msg_send_reply_receive (cfg_instance->ipc_ctx,
+	error = coroipcc_msg_send_reply_receive (cfg_instance->ipc_ctx,
 		&iov,
 		1,
 		&res_lib_cfg_statetrackstop,
@@ -612,7 +612,7 @@ corosync_cfg_admin_state_get (
 
 	pthread_mutex_lock (&cfg_instance->response_mutex);
 
-	error = cslib_msg_send_reply_receive (cfg_instance->ipc_ctx,
+	error = coroipcc_msg_send_reply_receive (cfg_instance->ipc_ctx,
 		&iov,
 		1,
 		&res_lib_cfg_administrativestateget,
@@ -657,7 +657,7 @@ corosync_cfg_admin_state_set (
 
 	pthread_mutex_lock (&cfg_instance->response_mutex);
 
-	error = cslib_msg_send_reply_receive (cfg_instance->ipc_ctx,
+	error = coroipcc_msg_send_reply_receive (cfg_instance->ipc_ctx,
 		&iov,
 		1,
 		&res_lib_cfg_administrativestateset,
@@ -704,7 +704,7 @@ corosync_cfg_kill_node (
 
 	pthread_mutex_lock (&cfg_instance->response_mutex);
 
-	error = cslib_msg_send_reply_receive (cfg_instance->ipc_ctx,
+	error = coroipcc_msg_send_reply_receive (cfg_instance->ipc_ctx,
 		&iov,
 		1,
 		&res_lib_cfg_killnode,
@@ -745,7 +745,7 @@ corosync_cfg_try_shutdown (
 
 	pthread_mutex_lock (&cfg_instance->response_mutex);
 
-	error = cslib_msg_send_reply_receive (cfg_instance->ipc_ctx,
+	error = coroipcc_msg_send_reply_receive (cfg_instance->ipc_ctx,
 		&iov,
 		1,
 		&res_lib_cfg_tryshutdown,
@@ -784,7 +784,7 @@ corosync_cfg_replyto_shutdown (
 
 	pthread_mutex_lock (&cfg_instance->response_mutex);
 
-	error = cslib_msg_send_reply_receive (cfg_instance->ipc_ctx,
+	error = coroipcc_msg_send_reply_receive (cfg_instance->ipc_ctx,
 		&iov,
 		1,
 		&res_lib_cfg_replytoshutdown,
@@ -826,7 +826,7 @@ cs_error_t corosync_cfg_get_node_addrs (
 
 	pthread_mutex_lock (&cfg_instance->response_mutex);
 
-	error = cslib_msg_send_reply_receive_in_buf (cfg_instance->ipc_ctx,
+	error = coroipcc_msg_send_reply_receive_in_buf (cfg_instance->ipc_ctx,
 		&iov,
 		1,
 		&return_address);
@@ -890,7 +890,7 @@ cs_error_t corosync_cfg_local_get (
 
 	pthread_mutex_lock (&cfg_inst->response_mutex);
 
-	error = cslib_msg_send_reply_receive (
+	error = coroipcc_msg_send_reply_receive (
 		cfg_inst->ipc_ctx,
 		&iov,
 		1,

+ 22 - 22
lib/confdb.c

@@ -48,7 +48,7 @@
 #include <corosync/confdb.h>
 #include <corosync/ipc_confdb.h>
 #include <corosync/mar_gen.h>
-#include <corosync/coroipc.h>
+#include <corosync/coroipcc.h>
 #include <corosync/list.h>
 
 #include "sa-confdb.h"
@@ -160,7 +160,7 @@ cs_error_t confdb_initialize (
 		confdb_inst->standalone = 1;
 	}
 	else {
-		error = cslib_service_connect (CONFDB_SERVICE, &confdb_inst->ipc_ctx);
+		error = coroipcc_service_connect (IPC_SOCKET_NAME, CONFDB_SERVICE, &confdb_inst->ipc_ctx);
 	}
 	if (error != CS_OK)
 		goto error_put_destroy;
@@ -218,7 +218,7 @@ cs_error_t confdb_finalize (
 	free_context_list(confdb_inst, &confdb_inst->key_iter_head);
 
 	if (!confdb_inst->standalone) {
-		cslib_service_disconnect (confdb_inst->ipc_ctx);
+		coroipcc_service_disconnect (confdb_inst->ipc_ctx);
 	}
 
 	(void)saHandleDestroy (&confdb_handle_t_db, handle);
@@ -240,7 +240,7 @@ cs_error_t confdb_fd_get (
 		return (error);
 	}
 
-	*fd = cslib_fd_get (confdb_inst->ipc_ctx);
+	*fd = coroipcc_fd_get (confdb_inst->ipc_ctx);
 
 	(void)saHandleInstancePut (&confdb_handle_t_db, handle);
 
@@ -326,7 +326,7 @@ cs_error_t confdb_dispatch (
 	do {
 		pthread_mutex_lock (&confdb_inst->dispatch_mutex);
 
-		dispatch_avail = cslib_dispatch_recv (confdb_inst->ipc_ctx,
+		dispatch_avail = coroipcc_dispatch_recv (confdb_inst->ipc_ctx,
 			(void *)&dispatch_data, timeout);
 
 
@@ -458,7 +458,7 @@ cs_error_t confdb_object_create (
 
 	pthread_mutex_lock (&confdb_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		confdb_inst->ipc_ctx,
 		&iov,
 		1,
@@ -511,7 +511,7 @@ cs_error_t confdb_object_destroy (
 
 	pthread_mutex_lock (&confdb_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		confdb_inst->ipc_ctx,
 		&iov,
 		1,
@@ -564,7 +564,7 @@ cs_error_t confdb_object_parent_get (
 
 	pthread_mutex_lock (&confdb_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		confdb_inst->ipc_ctx,
 		&iov,
 		1,
@@ -614,7 +614,7 @@ static cs_error_t do_find_destroy(
 
 	pthread_mutex_lock (&confdb_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		confdb_inst->ipc_ctx,
 		&iov,
 		1,
@@ -724,7 +724,7 @@ cs_error_t confdb_key_create (
 
 	pthread_mutex_lock (&confdb_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		confdb_inst->ipc_ctx,
 		&iov,
 		1,
@@ -786,7 +786,7 @@ cs_error_t confdb_key_delete (
 
 	pthread_mutex_lock (&confdb_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		confdb_inst->ipc_ctx,
 		&iov,
 		1,
@@ -846,7 +846,7 @@ cs_error_t confdb_key_get (
 
 	pthread_mutex_lock (&confdb_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		confdb_inst->ipc_ctx,
 		&iov,
 		1,
@@ -909,7 +909,7 @@ cs_error_t confdb_key_increment (
 
 	pthread_mutex_lock (&confdb_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		confdb_inst->ipc_ctx,
 		&iov,
 		1,
@@ -971,7 +971,7 @@ cs_error_t confdb_key_decrement (
 
 	pthread_mutex_lock (&confdb_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		confdb_inst->ipc_ctx,
 		&iov,
 		1,
@@ -1040,7 +1040,7 @@ cs_error_t confdb_key_replace (
 
 	pthread_mutex_lock (&confdb_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		confdb_inst->ipc_ctx,
 		&iov,
 		1,
@@ -1215,7 +1215,7 @@ cs_error_t confdb_object_find (
 
 	pthread_mutex_lock (&confdb_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		confdb_inst->ipc_ctx,
 		&iov,
 		1,
@@ -1287,7 +1287,7 @@ cs_error_t confdb_object_iter (
 
 	pthread_mutex_lock (&confdb_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		confdb_inst->ipc_ctx,
 		&iov,
 		1,
@@ -1362,7 +1362,7 @@ cs_error_t confdb_key_iter (
 
 	pthread_mutex_lock (&confdb_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		confdb_inst->ipc_ctx,
 		&iov,
 		1,
@@ -1422,7 +1422,7 @@ cs_error_t confdb_write (
 
 	pthread_mutex_lock (&confdb_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		confdb_inst->ipc_ctx,
 		&iov,
 		1,
@@ -1477,7 +1477,7 @@ cs_error_t confdb_reload (
 
 	pthread_mutex_lock (&confdb_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		confdb_inst->ipc_ctx,
 		&iov,
 		1,
@@ -1531,7 +1531,7 @@ cs_error_t confdb_track_changes (
 
 	pthread_mutex_lock (&confdb_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		confdb_inst->ipc_ctx,
 		&iov,
 		1,
@@ -1577,7 +1577,7 @@ cs_error_t confdb_stop_track_changes (confdb_handle_t handle)
 
 	pthread_mutex_lock (&confdb_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		confdb_inst->ipc_ctx,
 		&iov,
 		1,

+ 26 - 28
lib/coroipc.c → lib/coroipcc.c

@@ -59,7 +59,7 @@
 
 #include <corosync/corotypes.h>
 #include <corosync/ipc_gen.h>
-#include <corosync/coroipc.h>
+#include <corosync/coroipcc.h>
 
 enum SA_HANDLE_STATE {
 	SA_HANDLE_STATE_EMPTY,
@@ -88,12 +88,8 @@ struct ipc_segment {
 /* SUN_LEN is broken for abstract namespace 
  */
 #define AIS_SUN_LEN(a) sizeof(*(a))
-
-static const char *socketname = "libais.socket";
 #else
 #define AIS_SUN_LEN(a) SUN_LEN(a)
-
-static const char *socketname = SOCKETDIR "/libais.socket";
 #endif
 
 #ifdef SO_NOSIGPIPE
@@ -105,7 +101,7 @@ void socket_nosigpipe(int s)
 #endif 
 
 static int
-cslib_send (
+coroipcc_send (
 	int s,
 	void *msg,
 	size_t len)
@@ -181,7 +177,7 @@ error_exit:
 }
 
 static int
-cslib_recv (
+coroipcc_recv (
 	int s,
 	void *msg,
 	size_t len)
@@ -251,12 +247,12 @@ priv_change_send (struct ipc_segment *ipc_segment)
 	req_priv_change.egid = getegid();
 
 	buf_req = MESSAGE_REQ_CHANGE_EUID;
-	res = cslib_send (ipc_segment->fd, &buf_req, 1);
+	res = coroipcc_send (ipc_segment->fd, &buf_req, 1);
 	if (res == -1) {
 		return (-1);
 	}
 
-	res = cslib_send (ipc_segment->fd, &req_priv_change,
+	res = coroipcc_send (ipc_segment->fd, &req_priv_change,
 		sizeof (req_priv_change));
 	if (res == -1) {
 		return (-1);
@@ -267,7 +263,8 @@ priv_change_send (struct ipc_segment *ipc_segment)
 }
 	
 cs_error_t
-cslib_service_connect (
+coroipcc_service_connect (
+	const char *socket_name,
 	enum service_types service,
 	void **shmseg)
 {
@@ -293,10 +290,11 @@ cslib_service_connect (
 	address.sun_len = sizeof(struct sockaddr_un);
 #endif
 	address.sun_family = PF_UNIX;
+
 #if defined(COROSYNC_LINUX)
-	strcpy (address.sun_path + 1, socketname);
+	sprintf (address.sun_path + 1, "%s", socket_name);
 #else
-	strcpy (address.sun_path, socketname);
+	strcpy (address.sun_path, "%s%s", SOCKETDIR, socket_name);
 #endif
 	res = connect (request_fd, (struct sockaddr *)&address,
 		AIS_SUN_LEN(&address));
@@ -352,11 +350,11 @@ cslib_service_connect (
 	req_setup.semkey = semkey;
 	req_setup.service = service;
 
-	error = cslib_send (request_fd, &req_setup, sizeof (mar_req_setup_t));
+	error = coroipcc_send (request_fd, &req_setup, sizeof (mar_req_setup_t));
 	if (error != 0) {
 		goto error_exit;
 	}
-	error = cslib_recv (request_fd, &res_setup, sizeof (mar_res_setup_t));
+	error = coroipcc_recv (request_fd, &res_setup, sizeof (mar_res_setup_t));
 	if (error != 0) {
 		goto error_exit;
 	}
@@ -385,7 +383,7 @@ error_exit:
 }
 
 cs_error_t
-cslib_service_disconnect (
+coroipcc_service_disconnect (
 	void *ipc_context)
 {
 	struct ipc_segment *ipc_segment = (struct ipc_segment *)ipc_context;
@@ -398,7 +396,7 @@ cslib_service_disconnect (
 }
 
 int
-cslib_dispatch_flow_control_get (
+coroipcc_dispatch_flow_control_get (
         void *ipc_context)
 {
 	struct ipc_segment *ipc_segment = (struct ipc_segment *)ipc_context;
@@ -408,7 +406,7 @@ cslib_dispatch_flow_control_get (
 
 
 int
-cslib_fd_get (void *ipc_ctx)
+coroipcc_fd_get (void *ipc_ctx)
 {
 	struct ipc_segment *ipc_segment = (struct ipc_segment *)ipc_ctx;
 
@@ -441,7 +439,7 @@ static void memcpy_swrap (
 int original_flow = -1;
 
 int
-cslib_dispatch_recv (void *ipc_ctx, void *data, int timeout)
+coroipcc_dispatch_recv (void *ipc_ctx, void *data, int timeout)
 {
 	struct pollfd ufds;
 	struct sembuf sop;
@@ -491,7 +489,7 @@ retry_recv:
 	 */
 	if (ipc_segment->flow_control_state) {
 		buf_two = MESSAGE_REQ_OUTQ_FLUSH;
-		res = cslib_send (ipc_segment->fd, &buf_two, 1);
+		res = coroipcc_send (ipc_segment->fd, &buf_two, 1);
 		assert (res == 0); //TODO
 	}
 	/*
@@ -547,7 +545,7 @@ retry_semop:
 }
 
 static cs_error_t
-cslib_msg_send (
+coroipcc_msg_send (
 	void *ipc_context,
 	struct iovec *iov,
 	int iov_len)
@@ -588,7 +586,7 @@ retry_semop:
 }
 
 static cs_error_t
-cslib_reply_receive (
+coroipcc_reply_receive (
 	void *ipc_context,
 	void *res_msg, int res_len)
 {
@@ -622,7 +620,7 @@ retry_semop:
 }
 
 static cs_error_t
-cslib_reply_receive_in_buf (
+coroipcc_reply_receive_in_buf (
 	void *ipc_context,
 	void **res_msg)
 {
@@ -656,7 +654,7 @@ retry_semop:
 }
 
 cs_error_t
-cslib_msg_send_reply_receive (
+coroipcc_msg_send_reply_receive (
 	void *ipc_context,
 	struct iovec *iov,
 	int iov_len,
@@ -665,12 +663,12 @@ cslib_msg_send_reply_receive (
 {
 	cs_error_t res;
 
-	res = cslib_msg_send (ipc_context, iov, iov_len);
+	res = coroipcc_msg_send (ipc_context, iov, iov_len);
 	if (res != CS_OK) {
 		return (res);
 	}
 
-	res = cslib_reply_receive (ipc_context, res_msg, res_len);
+	res = coroipcc_reply_receive (ipc_context, res_msg, res_len);
 	if (res != CS_OK) {
 		return (res);
 	}
@@ -679,7 +677,7 @@ cslib_msg_send_reply_receive (
 }
 
 cs_error_t
-cslib_msg_send_reply_receive_in_buf (
+coroipcc_msg_send_reply_receive_in_buf (
 	void *ipc_context,
 	struct iovec *iov,
 	int iov_len,
@@ -687,12 +685,12 @@ cslib_msg_send_reply_receive_in_buf (
 {
 	unsigned int res;
 
-	res = cslib_msg_send (ipc_context, iov, iov_len);
+	res = coroipcc_msg_send (ipc_context, iov, iov_len);
 	if (res != CS_OK) {
 		return (res);
 	}
 
-	res = cslib_reply_receive_in_buf (ipc_context, res_msg);
+	res = coroipcc_reply_receive_in_buf (ipc_context, res_msg);
 	if (res != CS_OK) {
 		return (res);
 	}

+ 15 - 15
lib/cpg.c

@@ -34,7 +34,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 /*
- * Provides a closed process group API using the cslib executive
+ * Provides a closed process group API using the coroipcc executive
  */
 
 #include <config.h>
@@ -51,7 +51,7 @@
 #include <corosync/cpg.h>
 #include <corosync/ipc_cpg.h>
 #include <corosync/mar_cpg.h>
-#include <corosync/coroipc.h>
+#include <corosync/coroipcc.h>
 
 struct cpg_inst {
 	void *ipc_ctx;
@@ -84,8 +84,8 @@ static void cpg_instance_destructor (void *instance)
 
 
 /**
- * @defgroup cpg_cslib The closed process group API
- * @ingroup cslib
+ * @defgroup cpg_coroipcc The closed process group API
+ * @ingroup coroipcc
  *
  * @{
  */
@@ -107,7 +107,7 @@ cs_error_t cpg_initialize (
 		goto error_destroy;
 	}
 
-	error = cslib_service_connect (CPG_SERVICE, &cpg_inst->ipc_ctx);
+	error = coroipcc_service_connect (IPC_SOCKET_NAME, CPG_SERVICE, &cpg_inst->ipc_ctx);
 	if (error != CS_OK) {
 		goto error_put_destroy;
 	}
@@ -154,7 +154,7 @@ cs_error_t cpg_finalize (
 
 	cpg_inst->finalize = 1;
 
-	cslib_service_disconnect (cpg_inst->ipc_ctx);
+	coroipcc_service_disconnect (cpg_inst->ipc_ctx);
 
 	pthread_mutex_unlock (&cpg_inst->response_mutex);
 
@@ -177,7 +177,7 @@ cs_error_t cpg_fd_get (
 		return (error);
 	}
 
-	*fd = cslib_fd_get (cpg_inst->ipc_ctx);
+	*fd = coroipcc_fd_get (cpg_inst->ipc_ctx);
 
 	saHandleInstancePut (&cpg_handle_t_db, handle);
 
@@ -265,7 +265,7 @@ cs_error_t cpg_dispatch (
 	do {
 		pthread_mutex_lock (&cpg_inst->dispatch_mutex);
 
-		dispatch_avail = cslib_dispatch_recv (cpg_inst->ipc_ctx,
+		dispatch_avail = coroipcc_dispatch_recv (cpg_inst->ipc_ctx,
 			(void *)&dispatch_data, timeout);
 
 		pthread_mutex_unlock (&cpg_inst->dispatch_mutex);
@@ -410,7 +410,7 @@ cs_error_t cpg_join (
 	iov[0].iov_base = &req_lib_cpg_trackstart;
 	iov[0].iov_len = sizeof (struct req_lib_cpg_trackstart);
 
-	error = cslib_msg_send_reply_receive (cpg_inst->ipc_ctx, iov, 1,
+	error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, iov, 1,
 		&res_lib_cpg_trackstart, sizeof (struct res_lib_cpg_trackstart));
 
 	if (error != CS_OK) {
@@ -428,7 +428,7 @@ cs_error_t cpg_join (
 	iov[0].iov_base = &req_lib_cpg_join;
 	iov[0].iov_len = sizeof (struct req_lib_cpg_join);
 
-	error = cslib_msg_send_reply_receive (cpg_inst->ipc_ctx, iov, 1,
+	error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, iov, 1,
 		&res_lib_cpg_join, sizeof (struct res_lib_cpg_join));
 
 	pthread_mutex_unlock (&cpg_inst->response_mutex);
@@ -471,7 +471,7 @@ cs_error_t cpg_leave (
 
 	pthread_mutex_lock (&cpg_inst->response_mutex);
 
-	error = cslib_msg_send_reply_receive (cpg_inst->ipc_ctx, iov, 1,
+	error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, iov, 1,
 		&res_lib_cpg_leave, sizeof (struct res_lib_cpg_leave));
 
 	pthread_mutex_unlock (&cpg_inst->response_mutex);
@@ -523,7 +523,7 @@ cs_error_t cpg_mcast_joined (
 
 	pthread_mutex_lock (&cpg_inst->response_mutex);
 
-	error = cslib_msg_send_reply_receive (cpg_inst->ipc_ctx, iov,
+	error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, iov,
 		iov_len + 1, &res_lib_cpg_mcast, sizeof (res_lib_cpg_mcast));
 
 	pthread_mutex_unlock (&cpg_inst->response_mutex);
@@ -566,7 +566,7 @@ cs_error_t cpg_membership_get (
 
 	pthread_mutex_lock (&cpg_inst->response_mutex);
 
-	error = cslib_msg_send_reply_receive (cpg_inst->ipc_ctx, &iov, 1,
+	error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, &iov, 1,
 		&res_lib_cpg_membership_get, sizeof (mar_res_header_t));
 
 	pthread_mutex_unlock (&cpg_inst->response_mutex);
@@ -617,7 +617,7 @@ cs_error_t cpg_local_get (
 
 	pthread_mutex_lock (&cpg_inst->response_mutex);
 
-	error = cslib_msg_send_reply_receive (cpg_inst->ipc_ctx, &iov, 1,
+	error = coroipcc_msg_send_reply_receive (cpg_inst->ipc_ctx, &iov, 1,
 		&res_lib_cpg_local_get, sizeof (res_lib_cpg_local_get));
 
 	pthread_mutex_unlock (&cpg_inst->response_mutex);
@@ -648,7 +648,7 @@ cs_error_t cpg_flow_control_state_get (
 		return (error);
 	}
 	
-	*flow_control_state = cslib_dispatch_flow_control_get (cpg_inst->ipc_ctx);
+	*flow_control_state = coroipcc_dispatch_flow_control_get (cpg_inst->ipc_ctx);
 
 	saHandleInstancePut (&cpg_handle_t_db, handle);
 

+ 13 - 13
lib/evs.c

@@ -35,7 +35,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 /*
- * Provides an extended virtual synchrony API using the cslib executive
+ * Provides an extended virtual synchrony API using the corosync executive
  */
 
 #include <config.h>
@@ -52,7 +52,7 @@
 #include <corosync/corotypes.h>
 #include <corosync/evs.h>
 #include <corosync/ipc_evs.h>
-#include <corosync/coroipc.h>
+#include <corosync/coroipcc.h>
 
 struct evs_inst {
 	void *ipc_ctx;
@@ -89,8 +89,8 @@ static void evs_instance_destructor (void *instance)
 
 
 /**
- * @defgroup evs_cslib The extended virtual synchrony passthrough API
- * @ingroup cslib
+ * @defgroup evs_coroipcc The extended virtual synchrony passthrough API
+ * @ingroup coroipcc
  *
  * @{
  */
@@ -117,7 +117,7 @@ evs_error_t evs_initialize (
 		goto error_destroy;
 	}
 
-	error = cslib_service_connect (EVS_SERVICE, &evs_inst->ipc_ctx);
+	error = coroipcc_service_connect (IPC_SOCKET_NAME, EVS_SERVICE, &evs_inst->ipc_ctx);
 	if (error != EVS_OK) {
 		goto error_put_destroy;
 	}
@@ -163,7 +163,7 @@ evs_error_t evs_finalize (
 
 	evs_inst->finalize = 1;
 
-	cslib_service_disconnect (evs_inst->ipc_ctx);
+	coroipcc_service_disconnect (evs_inst->ipc_ctx);
 
 	pthread_mutex_unlock (&evs_inst->response_mutex);
 
@@ -186,7 +186,7 @@ evs_error_t evs_fd_get (
 		return (error);
 	}
 
-	*fd = cslib_fd_get (evs_inst->ipc_ctx);
+	*fd = coroipcc_fd_get (evs_inst->ipc_ctx);
 
 	saHandleInstancePut (&evs_handle_t_db, handle);
 
@@ -222,7 +222,7 @@ evs_error_t evs_dispatch (
 	}
 
 	do {
-		dispatch_avail = cslib_dispatch_recv (evs_inst->ipc_ctx, (void *)&dispatch_data, timeout);
+		dispatch_avail = coroipcc_dispatch_recv (evs_inst->ipc_ctx, (void *)&dispatch_data, timeout);
 		if (dispatch_avail == -1) {
 			error = CS_ERR_LIBRARY;
 			goto error_nounlock;
@@ -341,7 +341,7 @@ evs_error_t evs_join (
 	
 	pthread_mutex_lock (&evs_inst->response_mutex);
 
-	error = cslib_msg_send_reply_receive (evs_inst->ipc_ctx, iov, 2,
+	error = coroipcc_msg_send_reply_receive (evs_inst->ipc_ctx, iov, 2,
 		&res_lib_evs_join, sizeof (struct res_lib_evs_join));
 
 	pthread_mutex_unlock (&evs_inst->response_mutex);
@@ -386,7 +386,7 @@ evs_error_t evs_leave (
 	
 	pthread_mutex_lock (&evs_inst->response_mutex);
 
-	error = cslib_msg_send_reply_receive (evs_inst->ipc_ctx, iov, 2,
+	error = coroipcc_msg_send_reply_receive (evs_inst->ipc_ctx, iov, 2,
 		&res_lib_evs_leave, sizeof (struct res_lib_evs_leave));
 
 	pthread_mutex_unlock (&evs_inst->response_mutex);
@@ -439,7 +439,7 @@ evs_error_t evs_mcast_joined (
 	
 	pthread_mutex_lock (&evs_inst->response_mutex);
 
-	error = cslib_msg_send_reply_receive (evs_inst->ipc_ctx, iov,
+	error = coroipcc_msg_send_reply_receive (evs_inst->ipc_ctx, iov,
 		iov_len + 1,
 		&res_lib_evs_mcast_joined,
 		sizeof (struct res_lib_evs_mcast_joined));
@@ -496,7 +496,7 @@ evs_error_t evs_mcast_groups (
 	
 	pthread_mutex_lock (&evs_inst->response_mutex);
 
-	error = cslib_msg_send_reply_receive (evs_inst->ipc_ctx, iov,
+	error = coroipcc_msg_send_reply_receive (evs_inst->ipc_ctx, iov,
 		iov_len + 2,
 		&res_lib_evs_mcast_groups,
 		sizeof (struct res_lib_evs_mcast_groups));
@@ -539,7 +539,7 @@ evs_error_t evs_membership_get (
 
 	pthread_mutex_lock (&evs_inst->response_mutex);
 
-	error = cslib_msg_send_reply_receive (evs_inst->ipc_ctx,
+	error = coroipcc_msg_send_reply_receive (evs_inst->ipc_ctx,
 		&iov,
 		1,
 		&res_lib_evs_membership_get,

+ 7 - 7
lib/libcfg.versions

@@ -17,13 +17,13 @@ COROSYNC_CFG_0.82 {
 		
 		
 	local:
-		cslib_service_connect;
-		cslib_service_disconnect;
-		cslib_dispatch_flow_control_get;
-		cslib_fd_get;
-		cslib_dispatch_recv;
-		cslib_msg_send_reply_receive;
-		cslib_msg_send_reply_receive_in_buf;
+		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;
 		saHandleCreate;
 		saHandleDestroy;
 		saHandleInstanceGet;

+ 7 - 7
lib/libconfdb.versions

@@ -23,13 +23,13 @@ COROSYNC_CONFDB_1.0 {
 		confdb_key_iter;
 
 	local:
-		cslib_service_connect;
-		cslib_service_disconnect;
-		cslib_dispatch_flow_control_get;
-		cslib_fd_get;
-		cslib_dispatch_recv;
-		cslib_msg_send_reply_receive;
-		cslib_msg_send_reply_receive_in_buf;
+		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;
 		saHandleCreate;
 		saHandleDestroy;
 		saHandleInstanceGet;

+ 0 - 16
lib/libcoroipc.versions

@@ -1,16 +0,0 @@
-# Version and symbol export for libipcutil.so
-
-COROSYNC_IPCUTIL_2.0 {
-	global:
-		cslib_service_connect;
-		cslib_service_disconnect;
-		cslib_dispatch_flow_control_get;
-		cslib_fd_get;
-		cslib_dispatch_recv;
-		cslib_msg_send_reply_receive;
-		cslib_msg_send_reply_receive_in_buf;
-		saHandleCreate;
-		saHandleDestroy;
-		saHandleInstanceGet;
-		saHandleInstancePut;
-};

+ 16 - 0
lib/libcoroipcc.versions

@@ -0,0 +1,16 @@
+# Version and symbol export for libipcutil.so
+
+COROSYNC_IPCUTIL_2.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;
+		saHandleCreate;
+		saHandleDestroy;
+		saHandleInstanceGet;
+		saHandleInstancePut;
+};

+ 7 - 7
lib/libcpg.versions

@@ -14,13 +14,13 @@ COROSYNC_CPG_1.0 {
 		cpg_context_set;
 
 	local:
-		cslib_service_connect;
-		cslib_service_disconnect;
-		cslib_dispatch_flow_control_get;
-		cslib_fd_get;
-		cslib_dispatch_recv;
-		cslib_msg_send_reply_receive;
-		cslib_msg_send_reply_receive_in_buf;
+		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;
 		saHandleCreate;
 		saHandleDestroy;
 		saHandleInstanceGet;

+ 7 - 7
lib/libevs.versions

@@ -13,13 +13,13 @@ COROSYNC_EVS_2.0 {
 		evs_membership_get;
 
 	local:
-		cslib_service_connect;
-		cslib_service_disconnect;
-		cslib_dispatch_flow_control_get;
-		cslib_fd_get;
-		cslib_dispatch_recv;
-		cslib_msg_send_reply_receive;
-		cslib_msg_send_reply_receive_in_buf;
+		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;
 		saHandleCreate;
 		saHandleDestroy;
 		saHandleInstanceGet;

+ 7 - 7
lib/libpload.versions

@@ -5,13 +5,13 @@ COROSYNC_PLOAD_1.0 {
 		pload_start;
 
 	local:
-		cslib_service_connect;
-		cslib_service_disconnect;
-		cslib_dispatch_flow_control_get;
-		cslib_fd_get;
-		cslib_dispatch_recv;
-		cslib_msg_send_reply_receive;
-		cslib_msg_send_reply_receive_in_buf;
+		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;
 		saHandleCreate;
 		saHandleDestroy;
 		saHandleInstanceGet;

+ 7 - 7
lib/libquorum.versions

@@ -10,13 +10,13 @@ OPENAIS_QUORUM_1.0 {
 		quorum_dispatch;
 
 	local:
-		cslib_service_connect;
-		cslib_service_disconnect;
-		cslib_dispatch_flow_control_get;
-		cslib_fd_get;
-		cslib_dispatch_recv;
-		cslib_msg_send_reply_receive;
-		cslib_msg_send_reply_receive_in_buf;
+		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;
 		saHandleCreate;
 		saHandleDestroy;
 		saHandleInstanceGet;

+ 7 - 7
lib/libvotequorum.versions

@@ -19,13 +19,13 @@ OPENAIS_VOTEQUORUM_1.0 {
 		votequorum_context_set;
 
 	local:
-		cslib_service_connect;
-		cslib_service_disconnect;
-		cslib_dispatch_flow_control_get;
-		cslib_fd_get;
-		cslib_dispatch_recv;
-		cslib_msg_send_reply_receive;
-		cslib_msg_send_reply_receive_in_buf;
+		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;
 		saHandleCreate;
 		saHandleDestroy;
 		saHandleInstanceGet;

+ 5 - 5
lib/pload.c

@@ -47,7 +47,7 @@
 #include <corosync/corotypes.h>
 #include <corosync/ipc_pload.h>
 #include <corosync/pload.h>
-#include <corosync/coroipc.h>
+#include <corosync/coroipcc.h>
 
 static void pload_instance_destructor (void *instance);
 
@@ -106,7 +106,7 @@ unsigned int pload_initialize (
 		goto error_destroy;
 	}
 
-	error = cslib_service_connect (PLOAD_SERVICE, pload_inst->ipc_ctx);
+	error = coroipcc_service_connect (IPC_SOCKET_NAME, PLOAD_SERVICE, pload_inst->ipc_ctx);
 	if (error != CS_OK) {
 		goto error_put_destroy;
 	}
@@ -151,7 +151,7 @@ unsigned int pload_finalize (
 
 	pload_inst->finalize = 1;
 
-	cslib_service_disconnect(pload_inst->ipc_ctx);
+	coroipcc_service_disconnect(pload_inst->ipc_ctx);
 
 	pthread_mutex_unlock (&pload_inst->response_mutex);
 
@@ -174,7 +174,7 @@ unsigned int pload_fd_get (
 		return (error);
 	}
 
-	*fd = cslib_fd_get (pload_inst->ipc_ctx); 
+	*fd = coroipcc_fd_get (pload_inst->ipc_ctx); 
 
 	(void)saHandleInstancePut (&pload_handle_t_db, handle);
 
@@ -209,7 +209,7 @@ unsigned int pload_start (
 	
 	pthread_mutex_lock (&pload_inst->response_mutex);
 
-	error = cslib_msg_send_reply_receive(pload_inst->ipc_ctx,
+	error = coroipcc_msg_send_reply_receive(pload_inst->ipc_ctx,
 		&iov,
 		1,
 		&res_lib_pload_start,

+ 8 - 8
lib/quorum.c

@@ -48,7 +48,7 @@
 #include <corosync/corotypes.h>
 #include <corosync/mar_gen.h>
 #include <corosync/ipc_gen.h>
-#include <corosync/coroipc.h>
+#include <corosync/coroipcc.h>
 #include "corosync/quorum.h"
 #include "corosync/ipc_quorum.h"
 
@@ -97,7 +97,7 @@ cs_error_t quorum_initialize (
 		goto error_destroy;
 	}
 
-	error = cslib_service_connect (QUORUM_SERVICE, &quorum_inst->ipc_ctx);
+	error = coroipcc_service_connect (IPC_SOCKET_NAME, QUORUM_SERVICE, &quorum_inst->ipc_ctx);
 	if (error != CS_OK) {
 		goto error_put_destroy;
 	}
@@ -145,7 +145,7 @@ cs_error_t quorum_finalize (
 
 	quorum_inst->finalize = 1;
 
-	cslib_service_disconnect (quorum_inst->ipc_ctx);
+	coroipcc_service_disconnect (quorum_inst->ipc_ctx);
 
 	pthread_mutex_unlock (&quorum_inst->response_mutex);
 
@@ -179,7 +179,7 @@ cs_error_t quorum_getquorate (
 	iov.iov_base = (char *)&req;
 	iov.iov_len = sizeof (req);
 
-       error = cslib_msg_send_reply_receive (
+       error = coroipcc_msg_send_reply_receive (
 		quorum_inst->ipc_ctx,
 		&iov,
 		1,
@@ -214,7 +214,7 @@ cs_error_t quorum_fd_get (
 		return (error);
 	}
 
-	*fd = cslib_fd_get (quorum_inst->ipc_ctx);
+	*fd = coroipcc_fd_get (quorum_inst->ipc_ctx);
 
 	(void)saHandleInstancePut (&quorum_handle_t_db, handle);
 
@@ -285,7 +285,7 @@ cs_error_t quorum_trackstart (
 	iov.iov_base = (char *)&req_lib_quorum_trackstart;
 	iov.iov_len = sizeof (struct req_lib_quorum_trackstart);
 
-       error = cslib_msg_send_reply_receive (
+       error = coroipcc_msg_send_reply_receive (
 		quorum_inst->ipc_ctx,
                 &iov,
                 1,
@@ -328,7 +328,7 @@ cs_error_t quorum_trackstop (
 	iov.iov_base = (char *)&req;
 	iov.iov_len = sizeof (req);
 
-       error = cslib_msg_send_reply_receive (
+       error = coroipcc_msg_send_reply_receive (
 		quorum_inst->ipc_ctx,
                 &iov,
                 1,
@@ -391,7 +391,7 @@ cs_error_t quorum_dispatch (
 	do {
 		pthread_mutex_lock (&quorum_inst->dispatch_mutex);
 
-		dispatch_avail = cslib_dispatch_recv (quorum_inst->ipc_ctx,
+		dispatch_avail = coroipcc_dispatch_recv (quorum_inst->ipc_ctx,
 			(void *)&dispatch_data, timeout);
 
 		/*

+ 1 - 1
lib/sa-confdb.c

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

+ 16 - 16
lib/votequorum.c

@@ -48,7 +48,7 @@
 
 #include <corosync/mar_gen.h>
 #include <corosync/ipc_gen.h>
-#include <corosync/coroipc.h>
+#include <corosync/coroipcc.h>
 #include "corosync/votequorum.h"
 #include "corosync/ipc_votequorum.h"
 
@@ -97,7 +97,7 @@ cs_error_t votequorum_initialize (
 		goto error_destroy;
 	}
 
-	error = cslib_service_connect (VOTEQUORUM_SERVICE, &votequorum_inst->ipc_ctx);
+	error = coroipcc_service_connect (IPC_SOCKET_NAME, VOTEQUORUM_SERVICE, &votequorum_inst->ipc_ctx);
 	if (error != CS_OK) {
 		goto error_put_destroy;
 	}
@@ -145,7 +145,7 @@ cs_error_t votequorum_finalize (
 
 	votequorum_inst->finalize = 1;
 
-	cslib_service_disconnect (votequorum_inst->ipc_ctx);
+	coroipcc_service_disconnect (votequorum_inst->ipc_ctx);
 
 	pthread_mutex_unlock (&votequorum_inst->response_mutex);
 
@@ -182,7 +182,7 @@ cs_error_t votequorum_getinfo (
 
 	pthread_mutex_lock (&votequorum_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		votequorum_inst->ipc_ctx,
 		&iov,
 		1,
@@ -236,7 +236,7 @@ cs_error_t votequorum_setexpected (
 
 	pthread_mutex_lock (&votequorum_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		votequorum_inst->ipc_ctx,
 		&iov,
 		1,
@@ -283,7 +283,7 @@ cs_error_t votequorum_setvotes (
 
 	pthread_mutex_lock (&votequorum_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		votequorum_inst->ipc_ctx,
 		&iov,
 		1,
@@ -334,7 +334,7 @@ cs_error_t votequorum_qdisk_register (
 
 	pthread_mutex_lock (&votequorum_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		votequorum_inst->ipc_ctx,
 		&iov,
 		1,
@@ -380,7 +380,7 @@ cs_error_t votequorum_qdisk_poll (
 
 	pthread_mutex_lock (&votequorum_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		votequorum_inst->ipc_ctx,
 		&iov,
 		1,
@@ -423,7 +423,7 @@ cs_error_t votequorum_qdisk_unregister (
 	iov.iov_base = (char *)&req_lib_votequorum_general;
 	iov.iov_len = sizeof (struct req_lib_votequorum_general);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		votequorum_inst->ipc_ctx,
 		&iov,
 		1,
@@ -470,7 +470,7 @@ cs_error_t votequorum_qdisk_getinfo (
 
 	pthread_mutex_lock (&votequorum_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		votequorum_inst->ipc_ctx,
 		&iov,
 		1,
@@ -518,7 +518,7 @@ cs_error_t votequorum_setstate (
 
 	pthread_mutex_lock (&votequorum_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		votequorum_inst->ipc_ctx,
 		&iov,
 		1,
@@ -562,7 +562,7 @@ cs_error_t votequorum_leaving (
 
 	pthread_mutex_lock (&votequorum_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		votequorum_inst->ipc_ctx,
 		&iov,
 		1,
@@ -609,7 +609,7 @@ cs_error_t votequorum_trackstart (
 
 	pthread_mutex_lock (&votequorum_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		votequorum_inst->ipc_ctx,
 		&iov,
 		1,
@@ -652,7 +652,7 @@ cs_error_t votequorum_trackstop (
 
 	pthread_mutex_lock (&votequorum_inst->response_mutex);
 
-        error = cslib_msg_send_reply_receive (
+        error = coroipcc_msg_send_reply_receive (
 		votequorum_inst->ipc_ctx,
 		&iov,
 		1,
@@ -725,7 +725,7 @@ cs_error_t votequorum_fd_get (
                 return (error);
         }
 
-	*fd = cslib_fd_get (votequorum_inst->ipc_ctx);
+	*fd = coroipcc_fd_get (votequorum_inst->ipc_ctx);
 
 	(void)saHandleInstancePut (&votequorum_handle_t_db, handle);
 
@@ -776,7 +776,7 @@ cs_error_t votequorum_dispatch (
 	do {
 		pthread_mutex_lock (&votequorum_inst->dispatch_mutex);
 
-		dispatch_avail = cslib_dispatch_recv (
+		dispatch_avail = coroipcc_dispatch_recv (
 			votequorum_inst->ipc_ctx,
 			(void *)&dispatch_data, timeout);
 

+ 1 - 0
man/Makefile.am

@@ -45,6 +45,7 @@ dist_man_MANS = \
 	evs_overview.8 \
 	logsys_overview.8 \
 	votequorum_overview.8 \
+	coroipc_overview.8 \
 	confdb_dispatch.3 \
 	confdb_fd_get.3 \
 	confdb_finalize.3 \

+ 176 - 0
man/coroipc_overview.8

@@ -0,0 +1,176 @@
+.\"/*
+.\" * 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.
+.\" */
+.TH COROIPC_OVERVIEW 8 2009-03-21 "corosync Man Page" "Corosync Cluster Engine Programmer's Manual"
+.SH OVERVIEW
+The coroipcs and coroipcc libraries provide a generically reusable very high
+performance shared memory IPC sytem for client and service applications.
+It supports many features including:
+.PP
+65536 user services and 65536 command ids per service.
+.PP
+Shared memory implementation for very high performance.
+.PP
+A synchronous request/response channel and asynchronous response channel
+per ipc connection.
+.PP
+User defined private data per IPC connection.
+.PP
+Ability to call a function per service on ipc connection and disconnection.
+.PP
+Authenticated IPC connection with ability for developer to define which
+UIDs and GIDs are valid at connection time.
+.PP
+Fully abstracted poll system so that any poll library may be used.
+.PP
+User defined selector for determining the proper function to call per
+service and id.
+
+.SH Description of the libraries
+There are two shared libraries available for developing IPC client applications.
+
+The first library is coroipcs.so which is responsible for the server
+implementation.  This library should be linked with the server and then
+initialized with coroipcs_init(3).
+
+Once the library is initialized, it will provide service to coroipcc.so library
+users.
+
+The second library is coroipcc.so which is responsible for the client
+implementation.  This library should be linked with the client and requires
+no initialization.  This library provides communication functions for sending
+and receiving synchronous requests, and also reading asynchronous message
+requests from the server.
+
+.SH Initializing the coroipcs library
+To use the coroipcs library, the developer creates a coroipcs_init_state
+structure and populates it with function names.  The functions do various
+operations described in coroipcs_init(3) man page.  Not all operations must
+be specified.  If some are missing, the corosync ipcs library will
+automatically populate the structure with internal versions which provide
+basic functionality.
+
+.SH Communicating with the coroipcc clients
+Every ipc connection is represented by a void * pointer which uniquely
+identifies the data set for the IPC connection.  Each IPC connection also
+contains user defined private data.  To obtain this private data pointer, the
+function coroipcs_private_data_get(3) function can be called.
+
+There are two channels for communication.  The primary channel is the
+synchronous request/response channel.  Another channel is available for out of
+band asynchronous responses from the server.
+
+To send a response on the syncronous channel,  coroipcs_response_send(3) or
+coroipcs_response_iov_send(3) should be used.  To send a message on the
+asynchronous channel, coroipcs_dispatch_send(3) or coroipc_dispatch_iov_send(3)
+should be used.
+
+.SH The abstracted poll system
+There are many different poll systems in use in applications.  They are usually
+intricately tied up in the implementation of the application and each provide
+different APIs and functionality.  To manage this, the coroipcs library
+provides callbacks in coroipcs_init(3) which should be called when a new
+connection should be added for accept system calls or to dispatch messages.
+
+These callbacks add the relevant fd to the application's poll system.  When the
+application poll system triggers the callback registered by the user defined
+poll adding functions, they then call either coroipc_handler_accept(3) or
+coroipc_handler_dispatch(3).
+
+.SH Initializing the coroipcc library
+No initialization is required in the coroipcc library.
+
+.SH Lifecycle of an IPC connection.
+An IPC connection is made to the server with coroipcc_service_connect(3).  This
+function connects to the server and requests channels be created for
+communication.  To disconnect, the client either exits or executes the
+function coroipcc_service_disconnect(3).
+
+.SH Synchronous communication
+There are two functions for sending a request and receiving a response.  The 
+first function coroipcc_msg_send_reply_receive(3) sends an iovector request
+and receives a response.  This function copies the response into the response 
+buffer.  the second function coroipcc_msg_end_reply_receive_in_buf(3) does not
+copy the response buffer and allows for zero-copy reading of the response
+when the lifetime of the response buffer is known.
+
+.SH Asynchronous communication
+The coroipcc_dispatch_recv(3) function receives an out-of-band asyncronous
+message.  Unlike the synchronous communication channel, the asynchronous
+messages are queued and can provide very high out-of-band performance.
+
+To determine when to call coroipcc_dispatch_recv(3) the corosync_fd_get(3) call
+is used to obtain a file descriptor used in the poll(2) or select(2) system
+calls.
+
+Finally the current dispatch flow control state can be obtained with
+coroipcc_flow_control_get(3).
+
+.SH Performance
+The ipc system is tuned for very high performance while also being comletely
+abstracted from the underlying poll mechanism and any internalisms required
+by the server.  The ipc system achieves such high performance by using shared
+memory as oppossed to slower techniques such as UNIX_PF sockets.
+
+We intend to do further development to allow syncronous requests to return
+messages in an asyncronous way to avoid blocking involved in the syncronous
+request/response model used today for higher throughput in some use cases.
+
+.SH Security
+The ipc system uses default operating system security mechanics to ensure
+ipc connections are validated.  A callback used with coroipcs_init(3) is called
+for every new ipc connection with the parameters of UID and GID.  The callback
+then determines if the UID and GID are authenticated for communication.  More
+about this topic can be viewed in the coroipcs_init(3) man page.
+
+.SH "SEE ALSO"
+.BR coroipcs_ipc_init (3),
+.BR coroipcs_ipc_exit (3),
+.BR coroipcs_private_data_get (3),
+.BR coroipcs_respone_send (3),
+.BR coroipcs_response_iov_send (3),
+.BR coroipcs_dispatch_send (3),
+.BR coroipcs_dispatch_iov_send (3),
+.BR coroipcs_refcount_inc (3),
+.BR coroipcs_refcount_dec (3),
+.BR coroipcs_handler_accept (3),
+.BR coroipcs_handler_dispatch (3),
+
+.BR cooripcc_service_connect (3),
+.BR coroipcc_service_disconnect (3),
+.BR coroipcc_msg_send_reply_receive (3),
+.BR coroipcc_msg_send_reply_receive_in_buf (3),
+.BR coroipcc_dispatch_recv (3),
+.BR coroipcc_fd_get(3),
+.BR coroipcc_dispatch_flow_control_get (3)
+