From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22239 invoked by alias); 11 May 2009 15:07:55 -0000 Received: (qmail 22232 invoked by alias); 11 May 2009 15:07:54 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_33,J_CHICKENPOX_65,J_CHICKENPOX_66,SPF_HELO_PASS X-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_33,J_CHICKENPOX_65,J_CHICKENPOX_66,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion2.fedora.phx.redhat.com Subject: cluster: STABLE3 - cman: More changes for the latest corosync API To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/STABLE3 X-Git-Reftype: branch X-Git-Oldrev: 7e6ec0be8f368c2991c1aabff27d39d63adb9486 X-Git-Newrev: af56607de98bb20578833a1261c5c263e9fffac7 From: Christine Caulfield Message-Id: <20090511150726.B833F1201EC@lists.fedorahosted.org> Date: Mon, 11 May 2009 15:07:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q2/txt/msg00248.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=af56607de98bb20578833a1261c5c263e9fffac7 Commit: af56607de98bb20578833a1261c5c263e9fffac7 Parent: 7e6ec0be8f368c2991c1aabff27d39d63adb9486 Author: Christine Caulfield AuthorDate: Mon May 11 16:06:46 2009 +0100 Committer: Christine Caulfield CommitterDate: Mon May 11 16:06:46 2009 +0100 cman: More changes for the latest corosync API In particular honouring constness of buffers Signed-off-by: Christine Caulfield --- cman/daemon/ais.c | 31 +++++++++++++++++-------------- cman/daemon/commands.c | 12 ++++++++++-- cman/daemon/commands.h | 2 +- cman/daemon/daemon.c | 2 +- cman/daemon/daemon.h | 2 +- 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/cman/daemon/ais.c b/cman/daemon/ais.c index 3e04dd6..598bff7 100644 --- a/cman/daemon/ais.c +++ b/cman/daemon/ais.c @@ -90,7 +90,7 @@ static void cman_confchg_fn(enum totem_configuration_type configuration_type, const unsigned int *left_list, size_t left_list_entries, const unsigned int *joined_list, size_t joined_list_entries, const struct memb_ring_id *ring_id); -static void cman_deliver_fn(unsigned int nodeid, const struct iovec *iovec, unsigned int iov_len, +static void cman_deliver_fn(unsigned int nodeid, const void *msg, unsigned int msg_len, int endian_conversion_required); static void cman_quorum_init(struct corosync_api_v1 *api, quorum_set_quorate_fn_t report); @@ -249,28 +249,31 @@ int comms_send_message(void *buf, int len, return corosync->tpg_joined_mcast(group_handle, iov, 2, totem_flags); } -// This assumes the iovec has only one element ... is it true ?? -static void cman_deliver_fn(unsigned int nodeid, const struct iovec *iovec, unsigned int iov_len, +static void cman_deliver_fn(unsigned int nodeid, const void *msg, unsigned int msg_len, int endian_conversion_required) { - struct cl_protheader *header = iovec->iov_base; - char *buf = iovec->iov_base; + const struct cl_protheader *original_header = msg; + struct cl_protheader header; + const char *buf = msg; P_AIS("deliver_fn source nodeid = %d, len=%d, endian_conv=%d\n", - nodeid, (int)iovec->iov_len, endian_conversion_required); + nodeid, msg_len, endian_conversion_required); if (endian_conversion_required) { - header->srcid = swab32(header->srcid); - header->tgtid = swab32(header->tgtid); - header->flags = swab32(header->flags); + header.srcid = swab32(original_header->srcid); + header.tgtid = swab32(original_header->tgtid); + header.flags = swab32(original_header->flags); + } + else { + memcpy(&header, original_header, sizeof(header)); } /* Only pass on messages for us or everyone */ - if (header->tgtid == our_nodeid() || - header->tgtid == 0) { - send_to_userport(header->srcport, header->tgtport, - header->srcid, header->tgtid, - buf + sizeof(struct cl_protheader), iovec->iov_len - sizeof(struct cl_protheader), + if (header.tgtid == our_nodeid() || + header.tgtid == 0) { + send_to_userport(header.srcport, header.tgtport, + header.srcid, header.tgtid, + buf + sizeof(struct cl_protheader), msg_len - sizeof(struct cl_protheader), endian_conversion_required); } } diff --git a/cman/daemon/commands.c b/cman/daemon/commands.c index 407e33b..11d72e6 100644 --- a/cman/daemon/commands.c +++ b/cman/daemon/commands.c @@ -1511,13 +1511,21 @@ int process_command(struct connection *con, int cmd, char *cmdbuf, int send_to_userport(unsigned char fromport, unsigned char toport, int nodeid, int tgtid, - char *recv_buf, int len, + const char *recv_buf, int len, int endian_conv) { int ret = -1; if (toport == 0) { - process_internal_message(recv_buf, nodeid, endian_conv); + + /* We need to make a private copy here so that the internal command + * processors can do byteswapping. + */ + char *newmsg = alloca(len); + if (!newmsg) + return -1; + memcpy(newmsg, recv_buf, len); + process_internal_message(newmsg, nodeid, endian_conv); ret = 0; } else { diff --git a/cman/daemon/commands.h b/cman/daemon/commands.h index 7b51309..af0b17a 100644 --- a/cman/daemon/commands.h +++ b/cman/daemon/commands.h @@ -5,7 +5,7 @@ extern void process_cnxman_message(char *data, char *addr, int addrlen, extern int send_to_userport(unsigned char fromport, unsigned char toport, int nodeid, int tgtnodeid, - char *recv_buf, int len, + const char *recv_buf, int len, int endian_conv); extern void clean_dead_listeners(void); extern void unbind_con(struct connection *con); diff --git a/cman/daemon/daemon.c b/cman/daemon/daemon.c index d74c454..326c828 100644 --- a/cman/daemon/daemon.c +++ b/cman/daemon/daemon.c @@ -425,7 +425,7 @@ int send_status_return(struct connection *con, uint32_t cmd, int status) return send_reply_message(con, (struct sock_header *)&msg); } -int send_data_reply(struct connection *con, int nodeid, int port, char *data, int len) +int send_data_reply(struct connection *con, int nodeid, int port, const char *data, int len) { char buf[len + sizeof(struct sock_data_header)]; struct sock_data_header *msg = (struct sock_data_header *)buf; diff --git a/cman/daemon/daemon.h b/cman/daemon/daemon.h index 6907de3..4c202ef 100644 --- a/cman/daemon/daemon.h +++ b/cman/daemon/daemon.h @@ -1,5 +1,5 @@ extern int send_status_return(struct connection *con, uint32_t cmd, int status); -extern int send_data_reply(struct connection *con, int nodeid, int port, char *data, int len); +extern int send_data_reply(struct connection *con, int nodeid, int port, const char *data, int len); extern void set_cman_timeout(int secs); extern void notify_listeners(struct connection *con, int reason, int arg); extern int num_listeners(void);