great work good for merge
regards -steve On Wed, 2010-02-10 at 18:15 +0100, Jan Friesse wrote: > Attached patches contain: > - cpg_ringid_get function implementation > - man page > > Regards, > Honza > plain text document attachment (0001-Ringid-implementations.patch) > From c622ee19d018d956181172bc74233f9b8e5c1f92 Mon Sep 17 00:00:00 2001 > From: Jan Friesse <[email protected]> > Date: Mon, 25 Jan 2010 18:01:32 +0100 > Subject: [PATCH 1/2] Ringid implementations > > --- > trunk/include/corosync/cpg.h | 12 ++++++++++++ > trunk/include/corosync/ipc_cpg.h | 14 ++++++++++++++ > trunk/lib/cpg.c | 25 +++++++++++++++++++++++++ > trunk/lib/libcpg.versions | 1 + > trunk/services/cpg.c | 6 ++++++ > 5 files changed, 58 insertions(+), 0 deletions(-) > > diff --git a/trunk/include/corosync/cpg.h b/trunk/include/corosync/cpg.h > index b5609df..90ffa81 100644 > --- a/trunk/include/corosync/cpg.h > +++ b/trunk/include/corosync/cpg.h > @@ -98,6 +98,11 @@ struct cpg_iteration_description_t { > uint32_t pid; > }; > > +struct cpg_ring_id { > + uint32_t nodeid; > + uint64_t seq; > +}; > + > typedef void (*cpg_deliver_fn_t) ( > cpg_handle_t handle, > const struct cpg_name *group_name, > @@ -240,6 +245,13 @@ cs_error_t cpg_iteration_next( > cs_error_t cpg_iteration_finalize ( > cpg_iteration_handle_t handle); > > +/* > + * Ring id support > + */ > +cs_error_t cpg_ringid_get ( > + cpg_handle_t handle, > + struct cpg_ring_id *ring_id); > + > #ifdef __cplusplus > } > #endif > diff --git a/trunk/include/corosync/ipc_cpg.h > b/trunk/include/corosync/ipc_cpg.h > index 7df1891..7af95be 100644 > --- a/trunk/include/corosync/ipc_cpg.h > +++ b/trunk/include/corosync/ipc_cpg.h > @@ -147,6 +147,19 @@ static inline void > marshall_from_mar_cpg_iteration_description_t( > marshall_from_mar_cpg_name_t (&dest->group, &src->group); > }; > > +typedef struct { > + mar_uint32_t nodeid __attribute__((aligned(8))); > + mar_uint64_t seq __attribute__((aligned(8))); > +} mar_cpg_ring_id_t; > + > +static inline void marshall_from_mar_cpg_ring_id_t ( > + struct cpg_ring_id *dest, > + const mar_cpg_ring_id_t *src) > +{ > + dest->nodeid = src->nodeid; > + dest->seq = src->seq; > +} > + > struct req_lib_cpg_join { > coroipc_request_header_t header __attribute__((aligned(8))); > mar_cpg_name_t group_name __attribute__((aligned(8))); > @@ -219,6 +232,7 @@ struct req_lib_cpg_membership { > > struct res_lib_cpg_confchg_callback { > coroipc_response_header_t header __attribute__((aligned(8))); > + mar_cpg_ring_id_t ring_id __attribute__((aligned(8))); > mar_cpg_name_t group_name __attribute__((aligned(8))); > mar_uint32_t member_list_entries __attribute__((aligned(8))); > mar_uint32_t joined_list_entries __attribute__((aligned(8))); > diff --git a/trunk/lib/cpg.c b/trunk/lib/cpg.c > index 780e79f..4475854 100644 > --- a/trunk/lib/cpg.c > +++ b/trunk/lib/cpg.c > @@ -64,6 +64,7 @@ struct cpg_inst { > int finalize; > cpg_callbacks_t callbacks; > void *context; > + struct cpg_ring_id ring_id; > struct list_head iteration_list_head; > }; > > @@ -336,6 +337,7 @@ cs_error_t cpg_dispatch ( > > res_cpg_confchg_callback = (struct > res_lib_cpg_confchg_callback *)dispatch_data; > > + marshall_from_mar_cpg_ring_id_t (&cpg_inst->ring_id, > &res_cpg_confchg_callback->ring_id); > for (i = 0; i < > res_cpg_confchg_callback->member_list_entries; i++) { > marshall_from_mar_cpg_address_t > (&member_list[i], > > &res_cpg_confchg_callback->member_list[i]); > @@ -901,4 +903,27 @@ error_exit: > return (error); > } > > +cs_error_t cpg_ringid_get ( > + cpg_handle_t handle, > + struct cpg_ring_id *ring_id) > +{ > + cs_error_t error; > + struct cpg_inst *cpg_inst; > + > + if (ring_id == NULL) { > + return (CS_ERR_INVALID_PARAM); > + } > + > + error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, > (void *)&cpg_inst)); > + if (error != CS_OK) { > + return (error); > + } > + > + memcpy (ring_id, &cpg_inst->ring_id, sizeof (struct cpg_ring_id)); > + > + hdb_handle_put (&cpg_handle_t_db, handle); > + > + return (error); > +} > + > /** @} */ > diff --git a/trunk/lib/libcpg.versions b/trunk/lib/libcpg.versions > index 21b0f0d..e2cc643 100644 > --- a/trunk/lib/libcpg.versions > +++ b/trunk/lib/libcpg.versions > @@ -14,6 +14,7 @@ COROSYNC_CPG_1.0 { > cpg_context_set; > cpg_zcb_alloc; > cpg_zcb_free; > + cpg_ringid_get; > > local: > coroipcc_service_connect; > diff --git a/trunk/services/cpg.c b/trunk/services/cpg.c > index 59d59b2..194db85 100644 > --- a/trunk/services/cpg.c > +++ b/trunk/services/cpg.c > @@ -160,6 +160,8 @@ static struct corosync_api_v1 *api = NULL; > > static enum cpg_sync_state my_sync_state = CPGSYNC_DOWNLIST; > > +static mar_cpg_ring_id_t last_sync_ring_id; > + > struct process_info { > unsigned int nodeid; > uint32_t pid; > @@ -422,6 +424,9 @@ static void cpg_sync_init ( > sizeof (unsigned int)); > my_member_list_entries = member_list_entries; > > + last_sync_ring_id.nodeid = ring_id->rep.nodeid; > + last_sync_ring_id.seq = ring_id->seq; > + > for (i = 0; i < my_member_list_entries; i++) { > if (my_member_list[i] < lowest_nodeid) { > lowest_nodeid = my_member_list[i]; > @@ -530,6 +535,7 @@ static int notify_lib_joinlist( > res->header.id = id; > res->header.error = CS_OK; > memcpy(&res->group_name, group_name, sizeof(mar_cpg_name_t)); > + memcpy (&res->ring_id, &last_sync_ring_id, sizeof (mar_cpg_ring_id_t)); > > for (iter = process_info_list_head.next; iter != > &process_info_list_head; iter = iter->next) { > struct process_info *pi=list_entry (iter, struct process_info, > list); > plain text document attachment (0002-Man-page.patch) > From 3f648e5b0e3a06976e6dc0fc468b39fa34be2118 Mon Sep 17 00:00:00 2001 > From: Jan Friesse <[email protected]> > Date: Wed, 10 Feb 2010 18:03:23 +0100 > Subject: [PATCH 2/2] Man page > > --- > trunk/man/Makefile.am | 1 + > trunk/man/cpg_ringid_get.3 | 89 > ++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 90 insertions(+), 0 deletions(-) > create mode 100644 trunk/man/cpg_ringid_get.3 > > diff --git a/trunk/man/Makefile.am b/trunk/man/Makefile.am > index 348bc5b..93eb027 100644 > --- a/trunk/man/Makefile.am > +++ b/trunk/man/Makefile.am > @@ -71,6 +71,7 @@ dist_man_MANS = \ > cpg_leave.3 \ > cpg_local_get.3 \ > cpg_mcast_joined.3 \ > + cpg_ringid_get.3 \ > cpg_zcb_mcast_joined.3 \ > cpg_zcb_alloc.3 \ > cpg_zcb_free.3 \ > diff --git a/trunk/man/cpg_ringid_get.3 b/trunk/man/cpg_ringid_get.3 > new file mode 100644 > index 0000000..87aa435 > --- /dev/null > +++ b/trunk/man/cpg_ringid_get.3 > @@ -0,0 +1,89 @@ > +.\"/* > +.\" * Copyright (c) 2010 Red Hat, Inc. > +.\" * > +.\" * All rights reserved. > +.\" * > +.\" * Author: Jan Friesse <[email protected]> > +.\" * > +.\" * 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 CPG_RINGID_GET 3 2010-02-10 "corosync Man Page" "Corosync Cluster Engine > Programmer's Manual" > +.SH NAME > +cpg_ringid_get \- Gets the last known ring id > +.SH SYNOPSIS > +.B #include <corosync/cpg.h> > +.sp > +.BI "cpg_ringid_get (cpg_handle_t " handle ", struct cpg_ring_id *" ring_id > "); > +.SH DESCRIPTION > +The > +.B cpg_ringid_get > +function is used to retrieve the last know ring id. Argument > +.I handle > +must be valid handle to cpg connection obtained by > +.B cpg_initialize(3). > + > +The > +.I ring_id > +argument is of type pointer to struct cpg_ring_id which is defined by the > structure: > + > +.nf > +struct cpg_ring_id { > + uint32_t nodeid; > + uint64_t seq; > +}; > +.fi > + > +where > +.I nodeid > +is ID of currently master node and > +.I seq > +is sequentional token number. > +.SH RETURN VALUE > +This call return CS_OK value if successful, otherwise and error is > returned. > +.SH ERRORS > +.TP > +CS_ERR_INVALID_PARAM > +.I ringid > +was NULL > +.SH "SEE ALSO" > +.BR cpg_overview (8), > +.BR cpg_initialize (3), > +.BR cpg_finalize (3), > +.BR cpg_fd_get (3), > +.BR cpg_dispatch (3), > +.BR cpg_join (3), > +.BR cpg_leave (3), > +.BR cpg_mcast_joined (3), > +.BR cpg_membership_get (3) > +.BR cpg_zcb_alloc (3) > +.BR cpg_zcb_free (3) > +.BR cpg_zcb_mcast_joined (3) > +.BR cpg_context_get (3) > +.BR cpg_context_set (3) > +.BR cpg_local_get (3) > + > +.PP > _______________________________________________ > Openais mailing list > [email protected] > https://lists.linux-foundation.org/mailman/listinfo/openais _______________________________________________ Openais mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/openais
