48#include <sys/socket.h>
69#define MAP_ANONYMOUS MAP_ANON
76#define MAX_RETRIES 100
88 qb_ipcc_connection_t *
c;
99static void cpg_inst_free (
void *inst);
118coroipcc_msg_send_reply_receive (
119 qb_ipcc_connection_t *c,
120 const struct iovec *iov,
121 unsigned int iov_len,
125 return qb_to_cs_error(qb_ipcc_sendv_recv(c, iov, iov_len, res_msg, res_len,
135static void cpg_inst_free (
void *inst)
143 struct qb_list_head *iter, *tmp_iter;
154 hdb_handle_destroy (&cpg_handle_t_db, handle);
191 goto error_no_destroy;
195 if (error !=
CS_OK) {
196 goto error_no_destroy;
200 if (error !=
CS_OK) {
207 goto error_put_destroy;
210 if (model_data != NULL) {
232 hdb_handle_put (&cpg_handle_t_db, *handle);
237 hdb_handle_put (&cpg_handle_t_db, *handle);
239 hdb_handle_destroy (&cpg_handle_t_db, *handle);
254 if (error !=
CS_OK) {
262 hdb_handle_put (&cpg_handle_t_db, handle);
277 error = coroipcc_msg_send_reply_receive (
cpg_inst->
c,
283 cpg_inst_finalize (
cpg_inst, handle);
284 hdb_handle_put (&cpg_handle_t_db, handle);
297 if (error !=
CS_OK) {
303 hdb_handle_put (&cpg_handle_t_db, handle);
316 if (error !=
CS_OK) {
322 hdb_handle_put (&cpg_handle_t_db, handle);
335 if (error !=
CS_OK) {
341 hdb_handle_put (&cpg_handle_t_db, handle);
354 if (error !=
CS_OK) {
360 hdb_handle_put (&cpg_handle_t_db, handle);
378 struct qb_ipc_response_header *dispatch_data;
384 struct qb_list_head *iter, *tmp_iter;
394 if (error !=
CS_OK) {
406 dispatch_data = (
struct qb_ipc_response_header *)dispatch_buf;
408 errno_res = qb_ipcc_event_recv (
432 if (error !=
CS_OK) {
442 switch (cpg_inst_copy.
model) {
447 switch (dispatch_data->id) {
455 marshall_from_mar_cpg_name_t (
457 &res_cpg_deliver_callback->group_name);
461 res_cpg_deliver_callback->nodeid,
462 res_cpg_deliver_callback->pid,
463 &res_cpg_deliver_callback->message,
464 res_cpg_deliver_callback->msglen);
470 marshall_from_mar_cpg_name_t (
472 &res_cpg_partial_deliver_callback->group_name);
477 assembly_data = NULL;
480 if (current_assembly_data->
nodeid == res_cpg_partial_deliver_callback->nodeid && current_assembly_data->
pid == res_cpg_partial_deliver_callback->pid) {
481 assembly_data = current_assembly_data;
494 qb_list_del (&assembly_data->
list);
498 assembly_data = NULL;
502 if (!assembly_data) {
507 assembly_data->
nodeid = res_cpg_partial_deliver_callback->nodeid;
508 assembly_data->
pid = res_cpg_partial_deliver_callback->pid;
509 assembly_data->
assembly_buf = malloc(res_cpg_partial_deliver_callback->msglen);
516 qb_list_init (&assembly_data->
list);
522 res_cpg_partial_deliver_callback->message, res_cpg_partial_deliver_callback->fraglen);
523 assembly_data->
assembly_buf_ptr += res_cpg_partial_deliver_callback->fraglen;
529 res_cpg_partial_deliver_callback->nodeid,
530 res_cpg_partial_deliver_callback->pid,
532 res_cpg_partial_deliver_callback->msglen);
535 qb_list_del (&assembly_data->
list);
549 for (i = 0; i < res_cpg_confchg_callback->member_list_entries; i++) {
553 left_list_start = res_cpg_confchg_callback->
member_list +
554 res_cpg_confchg_callback->member_list_entries;
555 for (i = 0; i < res_cpg_confchg_callback->left_list_entries; i++) {
556 marshall_from_mar_cpg_address_t (&left_list[i],
557 &left_list_start[i]);
559 joined_list_start = res_cpg_confchg_callback->
member_list +
560 res_cpg_confchg_callback->member_list_entries +
561 res_cpg_confchg_callback->left_list_entries;
562 for (i = 0; i < res_cpg_confchg_callback->joined_list_entries; i++) {
563 marshall_from_mar_cpg_address_t (&joined_list[i],
564 &joined_list_start[i]);
566 marshall_from_mar_cpg_name_t (
568 &res_cpg_confchg_callback->group_name);
573 res_cpg_confchg_callback->member_list_entries,
575 res_cpg_confchg_callback->left_list_entries,
577 res_cpg_confchg_callback->joined_list_entries);
582 for (i = 0; i < res_cpg_confchg_callback->left_list_entries; i++) {
585 if (current_assembly_data->
nodeid != left_list[i].
nodeid || current_assembly_data->
pid != left_list[i].
pid)
588 qb_list_del (¤t_assembly_data->
list);
590 free(current_assembly_data);
602 marshall_from_mar_cpg_ring_id_t (&
ring_id, &res_cpg_totem_confchg_callback->ring_id);
603 for (i = 0; i < res_cpg_totem_confchg_callback->member_list_entries; i++) {
604 totem_member_list[i] = res_cpg_totem_confchg_callback->
member_list[i];
609 res_cpg_totem_confchg_callback->member_list_entries,
638 hdb_handle_put (&cpg_handle_t_db, handle);
657 if (error !=
CS_OK) {
680 error = coroipcc_msg_send_reply_receive (
cpg_inst->
c, iov, 1,
683 if (error !=
CS_OK) {
688 error = response.header.error;
691 hdb_handle_put (&cpg_handle_t_db, handle);
711 if (error !=
CS_OK) {
725 error = coroipcc_msg_send_reply_receive (
cpg_inst->
c, iov, 1,
728 if (error !=
CS_OK) {
736 hdb_handle_put (&cpg_handle_t_db, handle);
745 int *member_list_entries)
760 if (member_list_entries == NULL) {
765 if (error !=
CS_OK) {
778 error = coroipcc_msg_send_reply_receive (
cpg_inst->
c, &iov, 1,
781 if (error !=
CS_OK) {
793 marshall_from_mar_cpg_address_t (&member_list[i],
799 hdb_handle_put (&cpg_handle_t_db, handle);
806 unsigned int *local_nodeid)
815 if (error !=
CS_OK) {
825 error = coroipcc_msg_send_reply_receive (
cpg_inst->
c, &iov, 1,
828 if (error !=
CS_OK) {
837 hdb_handle_put (&cpg_handle_t_db, handle);
850 if (error !=
CS_OK) {
856 hdb_handle_put (&cpg_handle_t_db, handle);
871 *buffer = malloc(size);
872 if (*buffer == NULL) {
895 iov[0].iov_base = msg;
896 iov[0].iov_len = msg_len;
905 const struct iovec *iovec,
906 unsigned int iov_len)
926 qb_ipcc_fc_enable_max_set(
cpg_inst->
c, 2);
928 while (error ==
CS_OK && sent < msg_len) {
935 iov[1].iov_len = iovec[i].iov_len - iov_sent;
941 else if ((sent + iov[1].iov_len) == msg_len) {
950 iov[1].iov_base = (
char *)iovec[i].iov_base + iov_sent;
953 error = coroipcc_msg_send_reply_receive (
cpg_inst->
c, iov, 2,
958 fprintf(stderr,
"sleep. counter=%d\n", retry_count);
966 iov_sent += iov[1].iov_len;
967 sent += iov[1].iov_len;
970 if (iov_sent >= iovec[i].iov_len) {
977 qb_ipcc_fc_enable_max_set(
cpg_inst->
c, 1);
986 const struct iovec *iovec,
987 unsigned int iov_len)
992 struct iovec iov[64];
997 if (error !=
CS_OK) {
1001 for (i = 0; i < iov_len; i++ ) {
1002 msg_len += iovec[i].iov_len;
1019 memcpy (&iov[1], iovec, iov_len *
sizeof (
struct iovec));
1021 qb_ipcc_fc_enable_max_set(
cpg_inst->
c, 2);
1023 qb_ipcc_fc_enable_max_set(
cpg_inst->
c, 1);
1026 hdb_handle_put (&cpg_handle_t_db, handle);
1047 if (cpg_iteration_handle == NULL) {
1063 if (error !=
CS_OK) {
1067 error =
hdb_error_to_cs (hdb_handle_create (&cpg_iteration_handle_t_db,
1069 if (error !=
CS_OK) {
1070 goto error_put_cpg_db;
1073 error =
hdb_error_to_cs (hdb_handle_get (&cpg_iteration_handle_t_db, *cpg_iteration_handle,
1075 if (error !=
CS_OK) {
1093 error = coroipcc_msg_send_reply_receive (
cpg_inst->
c,
1099 if (error !=
CS_OK) {
1100 goto error_put_destroy;
1109 hdb_handle_put (&cpg_iteration_handle_t_db, *cpg_iteration_handle);
1110 hdb_handle_put (&cpg_handle_t_db, handle);
1115 hdb_handle_put (&cpg_iteration_handle_t_db, *cpg_iteration_handle);
1117 hdb_handle_destroy (&cpg_iteration_handle_t_db, *cpg_iteration_handle);
1119 hdb_handle_put (&cpg_handle_t_db, handle);
1133 if (description == NULL) {
1137 error =
hdb_error_to_cs (hdb_handle_get (&cpg_iteration_handle_t_db, handle,
1139 if (error !=
CS_OK) {
1150 if (error !=
CS_OK) {
1157 if (error !=
CS_OK) {
1161 marshall_from_mar_cpg_iteration_description_t(
1168 hdb_handle_put (&cpg_iteration_handle_t_db, handle);
1183 error =
hdb_error_to_cs (hdb_handle_get (&cpg_iteration_handle_t_db, handle,
1185 if (error !=
CS_OK) {
1202 if (error !=
CS_OK) {
1212 hdb_handle_put (&cpg_iteration_handle_t_db, handle);
cs_dispatch_flags_t
The cs_dispatch_flags_t enum.
@ CS_DISPATCH_ONE_NONBLOCKING
cs_error_t qb_to_cs_error(int result)
qb_to_cs_error
cs_error_t
The cs_error_t enum.
#define CS_IPC_TIMEOUT_MS
cs_error_t cpg_flow_control_state_get(cpg_handle_t handle, cpg_flow_control_state_t *flow_control_state)
cpg_flow_control_state_get
cs_error_t cpg_iteration_next(cpg_iteration_handle_t handle, struct cpg_iteration_description_t *description)
cpg_iteration_next
cs_error_t cpg_model_initialize(cpg_handle_t *handle, cpg_model_t model, cpg_model_data_t *model_data, void *context)
Create a new cpg connection, initialize with model.
cs_error_t cpg_max_atomic_msgsize_get(cpg_handle_t handle, uint32_t *size)
Get maximum size of a message that will not be fragmented.
cs_error_t cpg_mcast_joined(cpg_handle_t handle, cpg_guarantee_t guarantee, const struct iovec *iovec, unsigned int iov_len)
Multicast to groups joined with cpg_join.
cs_error_t cpg_leave(cpg_handle_t handle, const struct cpg_name *group)
Leave one or more groups.
cs_error_t cpg_context_get(cpg_handle_t handle, void **context)
Get contexts for a CPG handle.
cs_error_t cpg_fd_get(cpg_handle_t handle, int *fd)
Get a file descriptor on which to poll.
cs_error_t cpg_join(cpg_handle_t handle, const struct cpg_name *group)
Join one or more groups.
cs_error_t cpg_zcb_free(cpg_handle_t handle, void *buffer)
cpg_zcb_free
cs_error_t cpg_iteration_finalize(cpg_iteration_handle_t handle)
cpg_iteration_finalize
cs_error_t cpg_zcb_alloc(cpg_handle_t handle, size_t size, void **buffer)
cpg_zcb_alloc
cs_error_t cpg_membership_get(cpg_handle_t handle, struct cpg_name *group_name, struct cpg_address *member_list, int *member_list_entries)
Get membership information from cpg.
cs_error_t cpg_initialize(cpg_handle_t *handle, cpg_callbacks_t *callbacks)
Create a new cpg connection.
cs_error_t cpg_local_get(cpg_handle_t handle, unsigned int *local_nodeid)
cpg_local_get
cs_error_t cpg_iteration_initialize(cpg_handle_t handle, cpg_iteration_type_t iteration_type, const struct cpg_name *group, cpg_iteration_handle_t *cpg_iteration_handle)
cpg_iteration_initialize
cs_error_t cpg_context_set(cpg_handle_t handle, void *context)
Set contexts for a CPG handle.
cs_error_t cpg_finalize(cpg_handle_t handle)
Close the cpg handle.
cs_error_t cpg_dispatch(cpg_handle_t handle, cs_dispatch_flags_t dispatch_types)
Dispatch messages and configuration changes.
cs_error_t cpg_zcb_mcast_joined(cpg_handle_t handle, cpg_guarantee_t guarantee, void *msg, size_t msg_len)
cpg_zcb_mcast_joined
cpg_flow_control_state_t
The cpg_flow_control_state_t enum.
#define CPG_MAX_NAME_LENGTH
cpg_guarantee_t
The cpg_guarantee_t enum.
cpg_iteration_type_t
The cpg_iteration_type_t enum.
uint64_t cpg_handle_t
cpg_handle_t
uint64_t cpg_iteration_handle_t
cpg_iteration_handle_t
cpg_model_t
The cpg_model_t enum.
#define CPG_MODEL_V1_DELIVER_INITIAL_TOTEM_CONF
@ CPG_FLOW_CONTROL_DISABLED
flow control is disabled - new messages may be sent
@ CPG_ITERATION_ONE_GROUP
@ CPG_ITERATION_NAME_ONLY
#define DECLARE_HDB_DATABASE
@ LIBCPG_PARTIAL_CONTINUED
@ MESSAGE_REQ_CPG_LOCAL_GET
@ MESSAGE_REQ_CPG_ITERATIONFINALIZE
@ MESSAGE_REQ_CPG_PARTIAL_MCAST
@ MESSAGE_REQ_CPG_ITERATIONINITIALIZE
@ MESSAGE_REQ_CPG_FINALIZE
@ MESSAGE_REQ_CPG_MEMBERSHIP
@ MESSAGE_REQ_CPG_ITERATIONNEXT
@ MESSAGE_RES_CPG_PARTIAL_DELIVER_CALLBACK
@ MESSAGE_RES_CPG_DELIVER_CALLBACK
@ MESSAGE_RES_CPG_TOTEM_CONFCHG_CALLBACK
@ MESSAGE_RES_CPG_CONFCHG_CALLBACK
cs_error_t hdb_error_to_cs(int res)
#define IPC_DISPATCH_SIZE
uint32_t assembly_buf_ptr
The cpg_callbacks_t struct.
cpg_deliver_fn_t cpg_deliver_fn
cpg_confchg_fn_t cpg_confchg_fn
struct qb_list_head assembly_list_head
struct qb_list_head iteration_list_head
cpg_model_v1_data_t model_v1_data
The cpg_iteration_description_t struct.
qb_ipcc_connection_t * conn
cpg_iteration_handle_t cpg_iteration_handle
hdb_handle_t executive_iteration_handle
The cpg_model_data_t struct.
The cpg_model_v1_data_t struct.
cpg_totem_confchg_fn_t cpg_totem_confchg_fn
cpg_confchg_fn_t cpg_confchg_fn
cpg_deliver_fn_t cpg_deliver_fn
The req_lib_cpg_finalize struct.
The req_lib_cpg_iterationfinalize struct.
The req_lib_cpg_iterationinitialize struct.
The req_lib_cpg_iterationnext struct.
The req_lib_cpg_join struct.
The req_lib_cpg_leave struct.
The req_lib_cpg_local_get struct.
The req_lib_cpg_mcast struct.
The req_lib_cpg_membership_get struct.
The req_lib_cpg_partial_mcast struct.
The res_lib_cpg_confchg_callback struct.
mar_cpg_address_t member_list[]
Message from another node.
The res_lib_cpg_finalize struct.
The res_lib_cpg_iterationfinalize struct.
The res_lib_cpg_iterationinitialize struct.
The res_lib_cpg_iterationnext struct.
The res_lib_cpg_join struct.
The res_lib_cpg_leave struct.
The res_lib_cpg_local_get struct.
The res_lib_cpg_membership_get struct.
mar_cpg_address_t member_list[PROCESSOR_COUNT_MAX]
The res_lib_cpg_partial_deliver_callback struct.
The res_lib_cpg_partial_send struct.
The res_lib_cpg_totem_confchg_callback struct.
mar_uint32_t member_list[]
struct memb_ring_id ring_id