public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: master - cman: make cmanbits plugin compile with latest corosync
@ 2009-02-19 14:43 Christine Caulfield
  0 siblings, 0 replies; only message in thread
From: Christine Caulfield @ 2009-02-19 14:43 UTC (permalink / raw)
  To: cluster-cvs-relay

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=74f837230c8a873bd64b1a09682eda6333bd775f
Commit:        74f837230c8a873bd64b1a09682eda6333bd775f
Parent:        17b939f6fc34bb8d3cadb3c7e72405710fd95e18
Author:        Christine Caulfield <ccaulfie@redhat.com>
AuthorDate:    Thu Feb 19 14:42:54 2009 +0000
Committer:     Christine Caulfield <ccaulfie@redhat.com>
CommitterDate: Thu Feb 19 14:42:54 2009 +0000

cman: make cmanbits plugin compile with latest corosync

It doesn't all work though ...

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
---
 cman/services/cman/lib/Makefile    |    2 +-
 cman/services/cman/lib/libcman.c   |   96 +++++++++++------------------------
 cman/services/cman/services/cman.c |   12 ++--
 3 files changed, 37 insertions(+), 73 deletions(-)

diff --git a/cman/services/cman/lib/Makefile b/cman/services/cman/lib/Makefile
index df9e240..0365c4f 100644
--- a/cman/services/cman/lib/Makefile
+++ b/cman/services/cman/lib/Makefile
@@ -15,5 +15,5 @@ CFLAGS += -I${ccsincdir} -I${cmanincdir}
 CFLAGS += -I${incdir}
 CFLAGS += -I../include 
 
-LDFLAGS += -L${corosynclibdir} -lcoroutil -lcfg -lvotequorum
+LDFLAGS += -L${corosynclibdir} -lcoroipc -lcfg -lvotequorum
 LDFLAGS += -L${ccslibdir} -lccs
diff --git a/cman/services/cman/lib/libcman.c b/cman/services/cman/lib/libcman.c
index 56ade49..56cd758 100644
--- a/cman/services/cman/lib/libcman.c
+++ b/cman/services/cman/lib/libcman.c
@@ -14,9 +14,9 @@
 #include <limits.h>
 
 #include <corosync/corotypes.h>
+#include <corosync/coroipc.h>
 #include <corosync/mar_gen.h>
 #include <corosync/ipc_gen.h>
-#include <corosync/ais_util.h>
 #include <corosync/cfg.h>
 #include <corosync/confdb.h>
 #include <corosync/votequorum.h>
@@ -32,8 +32,7 @@
 
 struct cman_inst {
 	int magic;
-	int response_fd;
-	int dispatch_fd;
+	void *ipc_ctx;
 	int finalize;
 	void *privdata;
 	cman_datacallback_t data_callback;
@@ -157,9 +156,7 @@ cman_handle_t cman_init (
 		return NULL;
 
 	memset(cman_inst, 0, sizeof(struct cman_inst));
-	error = saServiceConnect (&cman_inst->dispatch_fd,
-				  &cman_inst->response_fd,
-				  CMAN_SERVICE);
+	error = cslib_service_connect (CMAN_SERVICE, &cman_inst->ipc_ctx);
 	if (error != CS_OK) {
 		goto error;
 	}
@@ -228,10 +225,7 @@ int cman_finish (
 	/*
 	 * Disconnect from the server
 	 */
-	if (cman_inst->response_fd != -1) {
-		shutdown(cman_inst->response_fd, 0);
-		close(cman_inst->response_fd);
-	}
+	cslib_service_disconnect (&cman_inst->ipc_ctx);
 
 	return 0;
 }
@@ -265,8 +259,9 @@ int cman_start_recv_data (
 	iov[0].iov_base = (char *)&req_lib_cman_bind;
 	iov[0].iov_len = sizeof (struct req_lib_cman_bind);
 
-	error = saSendMsgReceiveReply (cman_inst->response_fd, iov, 1,
-		&res, sizeof (mar_res_header_t));
+        error = cslib_msg_send_reply_receive (cman_inst->ipc_ctx,
+					      iov, 1,
+					      &res, sizeof (mar_res_header_t));
 
 	pthread_mutex_unlock (&cman_inst->response_mutex);
 
@@ -300,8 +295,9 @@ int cman_end_recv_data (
 	iov[0].iov_base = (char *)&req;
 	iov[0].iov_len = sizeof (mar_req_header_t);
 
-	error = saSendMsgReceiveReply (cman_inst->response_fd, iov, 1,
-		&res, sizeof (mar_res_header_t));
+        error = cslib_msg_send_reply_receive (cman_inst->ipc_ctx,
+					      iov, 1,
+					      &res, sizeof (mar_res_header_t));
 
 	pthread_mutex_unlock (&cman_inst->response_mutex);
 
@@ -340,8 +336,9 @@ int cman_send_data(cman_handle_t handle, const void *message, int len, int flags
 	iov[0].iov_base = buf;
 	iov[0].iov_len = len+sizeof(struct req_lib_cman_sendmsg);
 
-	error = saSendMsgReceiveReply (cman_inst->response_fd, iov, 1,
-		&res, sizeof (mar_res_header_t));
+        error = cslib_msg_send_reply_receive (cman_inst->ipc_ctx,
+					      iov, 1,
+					      &res, sizeof (mar_res_header_t));
 
 	pthread_mutex_unlock (&cman_inst->response_mutex);
 
@@ -380,8 +377,9 @@ int cman_is_listening (
 	iov[0].iov_base = (char *)&req_lib_cman_is_listening;
 	iov[0].iov_len = sizeof (struct req_lib_cman_is_listening);
 
-	error = saSendMsgReceiveReply (cman_inst->response_fd, iov, 1,
-		&res_lib_cman_is_listening, sizeof (struct res_lib_cman_is_listening));
+        error = cslib_msg_send_reply_receive (cman_inst->ipc_ctx,
+					      iov, 1,
+					      &res_lib_cman_is_listening, sizeof (struct res_lib_cman_is_listening));
 
 	pthread_mutex_unlock (&cman_inst->response_mutex);
 
@@ -610,7 +608,7 @@ int cman_get_fd (
 	cman_inst = (struct cman_inst *)handle;
 	VALIDATE_HANDLE(cman_inst);
 
-	fd = cman_inst->dispatch_fd;
+	fd = cslib_fd_get (cman_inst->ipc_ctx);
 
 	return fd;
 }
@@ -746,9 +744,8 @@ int cman_dispatch (
 	cman_handle_t handle,
 	int dispatch_types)
 {
-	struct pollfd ufds;
 	int timeout = -1;
-	cs_error_t error;
+	cs_error_t error = CS_OK;
 	int cont = 1; /* always continue do loop except when set to 0 */
 	int dispatch_avail;
 	struct cman_inst *cman_inst;
@@ -774,32 +771,18 @@ int cman_dispatch (
 	}
 
 	do {
-		ufds.fd = cman_inst->dispatch_fd;
-		ufds.events = POLLIN;
-		ufds.revents = 0;
-
 		pthread_mutex_lock (&cman_inst->dispatch_mutex);
 
-		error = saPollRetry (&ufds, 1, timeout);
-		if (error != CS_OK) {
-			goto error_unlock;
-		}
+		dispatch_avail = cslib_dispatch_recv (cman_inst->ipc_ctx,
+			(void *)&dispatch_data, timeout);
 
-		/*
-		 * Handle has been finalized in another thread
-		 */
-		if (cman_inst->finalize == 1) {
-			error = CS_OK;
-			goto error_unlock;
-		}
+		pthread_mutex_unlock (&cman_inst->dispatch_mutex);
 
-		if ((ufds.revents & (POLLERR|POLLHUP|POLLNVAL)) != 0) {
-			error = CS_ERR_BAD_HANDLE;
-			goto error_unlock;
+		if (error != CS_OK) {
+			goto error_put;
 		}
 
-		dispatch_avail = ufds.revents & POLLIN;
-		if (dispatch_avail == 0 && dispatch_types == CS_DISPATCH_ALL) {
+		if (dispatch_avail == 0 && dispatch_types == CMAN_DISPATCH_ALL) {
 			pthread_mutex_unlock (&cman_inst->dispatch_mutex);
 			break; /* exit do while cont is 1 loop */
 		} else
@@ -807,30 +790,14 @@ int cman_dispatch (
 			pthread_mutex_unlock (&cman_inst->dispatch_mutex);
 			continue; /* next poll */
 		}
-
-		if (ufds.revents & POLLIN) {
-			error = saRecvRetry (cman_inst->dispatch_fd, &dispatch_data.header,
-				sizeof (mar_res_header_t));
-			if (error != CS_OK) {
-				goto error_unlock;
+		if (dispatch_avail == -1) {
+			if (cman_inst->finalize == 1) {
+				error = CS_OK;
+			} else {
+				error = CS_ERR_LIBRARY;
 			}
-			if (dispatch_data.header.size > sizeof (mar_res_header_t)) {
-				error = saRecvRetry (cman_inst->dispatch_fd, &dispatch_data.data,
-					dispatch_data.header.size - sizeof (mar_res_header_t));
-				if (error != CS_OK) {
-					goto error_unlock;
-				}
-			}
-		} else {
-			pthread_mutex_unlock (&cman_inst->dispatch_mutex);
-			continue;
+			goto error_put;
 		}
-
-		/*
-		 * Make copy of callbacks, message data, unlock instance, and call callback
-		 * A risk of this dispatch method is that the callback routines may
-		 * operate at the same time that cman_finalize has been called in another thread.
-		 */
 		pthread_mutex_unlock (&cman_inst->dispatch_mutex);
 
 		/*
@@ -874,9 +841,6 @@ int cman_dispatch (
 
 	goto error_put;
 
-error_unlock:
-	pthread_mutex_unlock (&cman_inst->dispatch_mutex);
-
 error_put:
 	return (error);
 }
diff --git a/cman/services/cman/services/cman.c b/cman/services/cman/services/cman.c
index fe61bc7..2001256 100644
--- a/cman/services/cman/services/cman.c
+++ b/cman/services/cman/services/cman.c
@@ -403,7 +403,7 @@ static void cman_deliver_fn(unsigned int nodeid, struct iovec *iovec, int iov_le
 		buf = iovec->iov_base + sizeof(struct cman_protheader);
 
 		if (ports[header->tgtport]) {
-			corosync_api->ipc_conn_send_response(ports[header->tgtport], buf,  iovec->iov_len - sizeof(struct cman_protheader));
+			corosync_api->ipc_response_send(ports[header->tgtport], buf,  iovec->iov_len - sizeof(struct cman_protheader));
 		}
 	}
 
@@ -472,7 +472,7 @@ static void message_handler_req_lib_cman_bind (void *conn, void *msg)
 	}
 	if (error == CS_OK) {
 		cman_pd->port = req_lib_cman_bind->port;
-		ports[cman_pd->port] = corosync_api->ipc_conn_partner_get(conn);
+		ports[cman_pd->port] = conn;
 
 		/* Tell the cluster */
 		portmsg[0] = CLUSTER_MSG_PORTOPENED;
@@ -483,7 +483,7 @@ static void message_handler_req_lib_cman_bind (void *conn, void *msg)
 	res.size = sizeof(res);
 	res.id = MESSAGE_RES_CMAN_BIND;
 	res.error = error;
-	corosync_api->ipc_conn_send_response(conn, &res, sizeof(res));
+	corosync_api->ipc_response_send(conn, &res, sizeof(res));
 }
 
 static void message_handler_req_lib_cman_unbind (void *conn, void *msg)
@@ -506,7 +506,7 @@ static void message_handler_req_lib_cman_unbind (void *conn, void *msg)
 	res.size = sizeof(res);
 	res.id = MESSAGE_RES_CMAN_UNBIND;
 	res.error = error;
-	corosync_api->ipc_conn_send_response(conn, &res, sizeof(res));
+	corosync_api->ipc_response_send(conn, &res, sizeof(res));
 }
 
 static void message_handler_req_lib_cman_sendmsg (void *conn, void *msg)
@@ -531,7 +531,7 @@ static void message_handler_req_lib_cman_sendmsg (void *conn, void *msg)
 	res.size = sizeof(res);
 	res.id = MESSAGE_RES_CMAN_SENDMSG;
 	res.error = error;
-	corosync_api->ipc_conn_send_response(conn, &res, sizeof(res));
+	corosync_api->ipc_response_send(conn, &res, sizeof(res));
 }
 
 static void message_handler_req_lib_cman_is_listening (void *conn, void *msg)
@@ -569,5 +569,5 @@ static void message_handler_req_lib_cman_is_listening (void *conn, void *msg)
 	res_lib_cman_is_listening.header.size = sizeof(res_lib_cman_is_listening);
 	res_lib_cman_is_listening.header.id = MESSAGE_RES_CMAN_SENDMSG;
 	res_lib_cman_is_listening.header.error = error;
-	corosync_api->ipc_conn_send_response(conn, &res_lib_cman_is_listening, sizeof(res_lib_cman_is_listening));
+	corosync_api->ipc_response_send(conn, &res_lib_cman_is_listening, sizeof(res_lib_cman_is_listening));
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-02-19 14:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-19 14:43 cluster: master - cman: make cmanbits plugin compile with latest corosync Christine Caulfield

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).