41 #include <sys/types.h>
42 #include <sys/socket.h>
44 #include <sys/ioctl.h>
45 #include <netinet/in.h>
55 #include <netinet/in.h>
56 #include <arpa/inet.h>
61 #include <qb/qbipc_common.h>
71 #define MAP_ANONYMOUS MAP_ANON
78 #define GROUP_HASH_SIZE 32
149 static struct list_head downlist_messages_head;
150 static struct list_head joinlist_messages_head;
177 static unsigned int my_member_list_entries;
181 static unsigned int my_old_member_list_entries = 0;
207 static int cpg_lib_init_fn (
void *conn);
209 static int cpg_lib_exit_fn (
void *conn);
211 static void message_handler_req_exec_cpg_procjoin (
215 static void message_handler_req_exec_cpg_procleave (
219 static void message_handler_req_exec_cpg_joinlist (
223 static void message_handler_req_exec_cpg_mcast (
227 static void message_handler_req_exec_cpg_downlist_old (
231 static void message_handler_req_exec_cpg_downlist (
235 static void exec_cpg_procjoin_endian_convert (
void *msg);
237 static void exec_cpg_joinlist_endian_convert (
void *msg);
239 static void exec_cpg_mcast_endian_convert (
void *msg);
241 static void exec_cpg_downlist_endian_convert_old (
void *msg);
243 static void exec_cpg_downlist_endian_convert (
void *msg);
245 static void message_handler_req_lib_cpg_join (
void *conn,
const void *message);
247 static void message_handler_req_lib_cpg_leave (
void *conn,
const void *message);
249 static void message_handler_req_lib_cpg_finalize (
void *conn,
const void *message);
251 static void message_handler_req_lib_cpg_mcast (
void *conn,
const void *message);
253 static void message_handler_req_lib_cpg_membership (
void *conn,
254 const void *message);
256 static void message_handler_req_lib_cpg_local_get (
void *conn,
257 const void *message);
259 static void message_handler_req_lib_cpg_iteration_initialize (
261 const void *message);
263 static void message_handler_req_lib_cpg_iteration_next (
265 const void *message);
267 static void message_handler_req_lib_cpg_iteration_finalize (
269 const void *message);
271 static void message_handler_req_lib_cpg_zc_alloc (
273 const void *message);
275 static void message_handler_req_lib_cpg_zc_free (
277 const void *message);
279 static void message_handler_req_lib_cpg_zc_execute (
281 const void *message);
283 static int cpg_node_joinleave_send (
unsigned int pid,
const mar_cpg_name_t *group_name,
int fn,
int reason);
285 static int cpg_exec_send_downlist(
void);
287 static int cpg_exec_send_joinlist(
void);
289 static void downlist_messages_delete (
void);
291 static void downlist_master_choose_and_send (
void);
293 static void joinlist_inform_clients (
void);
295 static void joinlist_messages_delete (
void);
297 static void cpg_sync_init (
298 const unsigned int *trans_list,
299 size_t trans_list_entries,
300 const unsigned int *member_list,
301 size_t member_list_entries,
304 static int cpg_sync_process (
void);
306 static void cpg_sync_activate (
void);
308 static void cpg_sync_abort (
void);
310 static void do_proc_join(
316 static int notify_lib_totem_membership (
318 int member_list_entries,
319 const unsigned int *member_list);
321 static inline int zcb_all_free (
324 static char *cpg_print_group_name (
337 .lib_handler_fn = message_handler_req_lib_cpg_leave,
341 .lib_handler_fn = message_handler_req_lib_cpg_mcast,
345 .lib_handler_fn = message_handler_req_lib_cpg_membership,
349 .lib_handler_fn = message_handler_req_lib_cpg_local_get,
353 .lib_handler_fn = message_handler_req_lib_cpg_iteration_initialize,
357 .lib_handler_fn = message_handler_req_lib_cpg_iteration_next,
361 .lib_handler_fn = message_handler_req_lib_cpg_iteration_finalize,
365 .lib_handler_fn = message_handler_req_lib_cpg_finalize,
369 .lib_handler_fn = message_handler_req_lib_cpg_zc_alloc,
373 .lib_handler_fn = message_handler_req_lib_cpg_zc_free,
377 .lib_handler_fn = message_handler_req_lib_cpg_zc_execute,
388 .exec_endian_convert_fn = exec_cpg_procjoin_endian_convert
391 .exec_handler_fn = message_handler_req_exec_cpg_procleave,
392 .exec_endian_convert_fn = exec_cpg_procjoin_endian_convert
395 .exec_handler_fn = message_handler_req_exec_cpg_joinlist,
396 .exec_endian_convert_fn = exec_cpg_joinlist_endian_convert
399 .exec_handler_fn = message_handler_req_exec_cpg_mcast,
400 .exec_endian_convert_fn = exec_cpg_mcast_endian_convert
403 .exec_handler_fn = message_handler_req_exec_cpg_downlist_old,
404 .exec_endian_convert_fn = exec_cpg_downlist_endian_convert_old
407 .exec_handler_fn = message_handler_req_exec_cpg_downlist,
408 .exec_endian_convert_fn = exec_cpg_downlist_endian_convert
413 .
name =
"corosync cluster closed process group service v1.01",
416 .private_data_size =
sizeof (
struct cpg_pd),
419 .lib_init_fn = cpg_lib_init_fn,
420 .lib_exit_fn = cpg_lib_exit_fn,
421 .lib_engine = cpg_lib_engine,
423 .exec_init_fn = cpg_exec_init_fn,
424 .exec_dump_fn = NULL,
425 .exec_engine = cpg_exec_engine,
427 .sync_init = cpg_sync_init,
428 .sync_process = cpg_sync_process,
429 .sync_activate = cpg_sync_activate,
430 .sync_abort = cpg_sync_abort
435 return (&cpg_service_engine);
439 struct qb_ipc_request_header header __attribute__((aligned(8)));
446 struct qb_ipc_request_header header __attribute__((aligned(8)));
455 struct qb_ipc_request_header header __attribute__((aligned(8)));
461 struct qb_ipc_request_header header __attribute__((aligned(8)));
496 for (i = 0; i < group->length; i++) {
499 if (c >=
' ' && c < 0x7f && c !=
'\\') {
503 res[dest_pos++] =
'\\';
504 res[dest_pos++] =
'\\';
506 snprintf(res + dest_pos,
sizeof(res) - dest_pos,
"\\x%02X", c);
516 static void cpg_sync_init (
517 const unsigned int *trans_list,
518 size_t trans_list_entries,
519 const unsigned int *member_list,
520 size_t member_list_entries,
529 memcpy (my_member_list, member_list, member_list_entries *
530 sizeof (
unsigned int));
531 my_member_list_entries = member_list_entries;
533 last_sync_ring_id.nodeid = ring_id->
rep.
nodeid;
534 last_sync_ring_id.seq = ring_id->
seq;
542 for (i = 0; i < my_old_member_list_entries; i++) {
544 for (j = 0; j < trans_list_entries; j++) {
545 if (my_old_member_list[i] == trans_list[j]) {
551 g_req_exec_cpg_downlist.nodeids[entries++] =
552 my_old_member_list[i];
555 g_req_exec_cpg_downlist.left_nodes = entries;
558 static int cpg_sync_process (
void)
563 res = cpg_exec_send_downlist();
570 res = cpg_exec_send_joinlist();
575 static void cpg_sync_activate (
void)
577 memcpy (my_old_member_list, my_member_list,
578 my_member_list_entries *
sizeof (
unsigned int));
579 my_old_member_list_entries = my_member_list_entries;
582 downlist_master_choose_and_send ();
585 joinlist_inform_clients ();
587 downlist_messages_delete ();
589 joinlist_messages_delete ();
591 notify_lib_totem_membership (NULL, my_member_list_entries, my_member_list);
594 static void cpg_sync_abort (
void)
597 downlist_messages_delete ();
598 joinlist_messages_delete ();
601 static int notify_lib_totem_membership (
603 int member_list_entries,
604 const unsigned int *member_list)
618 res->member_list_entries = member_list_entries;
619 res->header.size = size;
621 res->header.error =
CS_OK;
627 for (iter = cpg_pd_list_head.
next; iter != &cpg_pd_list_head; iter = iter->
next) {
638 static int notify_lib_joinlist(
641 int joined_list_entries,
643 int left_list_entries,
656 for (iter = process_info_list_head.
next; iter != &process_info_list_head; iter = iter->
next) {
658 if (mar_name_compare (&pi->
group, group_name) == 0) {
662 for (i = 0; i < left_list_entries; i++) {
663 if (left_list[i].
nodeid == pi->
nodeid && left_list[i].pid == pi->
pid) {
680 res->joined_list_entries = joined_list_entries;
681 res->left_list_entries = left_list_entries;
682 res->member_list_entries = count;
684 res->header.size = size;
686 res->header.error =
CS_OK;
689 for (iter = process_info_list_head.
next; iter != &process_info_list_head; iter = iter->
next) {
692 if (mar_name_compare (&pi->
group, group_name) == 0) {
696 for (i = 0;i < left_list_entries; i++) {
697 if (left_list[i].
nodeid == pi->
nodeid && left_list[i].pid == pi->
pid) {
703 retgi->nodeid = pi->
nodeid;
704 retgi->pid = pi->
pid;
710 if (left_list_entries) {
712 retgi += left_list_entries;
715 if (joined_list_entries) {
717 retgi += joined_list_entries;
723 for (iter = cpg_pd_list_head.
next; iter != &cpg_pd_list_head; iter = iter->
next) {
725 if (mar_name_compare (&cpd->
group_name, group_name) == 0) {
726 assert (joined_list_entries <= 1);
727 if (joined_list_entries) {
728 if (joined_list[0].
pid == cpd->
pid &&
738 if (left_list_entries) {
739 if (left_list[0].
pid == cpd->
pid &&
756 for (iter = cpg_pd_list_head.
next; iter != &cpg_pd_list_head; iter = iter->
next) {
762 notify_lib_totem_membership (cpd->
conn, my_old_member_list_entries, my_old_member_list);
769 static void downlist_log(
const char *msg,
struct downlist_msg* dl)
772 "%s: sender %s; members(old:%d left:%d)",
779 static struct downlist_msg* downlist_master_choose (
void)
784 uint32_t cmp_members;
785 uint32_t best_members;
789 for (iter = downlist_messages_head.
next;
790 iter != &downlist_messages_head;
794 downlist_log(
"comparing", cmp);
797 for (i = 0; i < cmp->left_nodes; i++) {
799 log_printf (LOG_DEBUG,
"Ignoring this entry because I'm in the left list\n");
815 best_members = best->old_members - best->left_nodes;
816 cmp_members = cmp->old_members - cmp->left_nodes;
818 if (cmp_members > best_members) {
820 }
else if (cmp_members == best_members) {
821 if (cmp->old_members > best->old_members) {
823 }
else if (cmp->old_members == best->old_members) {
831 assert (best != NULL);
836 static void downlist_master_choose_and_send (
void)
847 int left_list_entries;
850 qb_map_iter_t *miter;
855 stored_msg = downlist_master_choose ();
860 downlist_log(
"chosen downlist", stored_msg);
862 group_map = qb_skiplist_create();
869 for (iter = process_info_list_head.
next; iter != &process_info_list_head; ) {
874 for (i = 0; i < stored_msg->left_nodes; i++) {
876 if (pi->
nodeid == stored_msg->nodeids[i]) {
883 marshall_from_mar_cpg_name_t(&cpg_group, &left_pi->
group);
884 cpg_group.value[cpg_group.length] = 0;
886 pcd = (
struct confchg_data *)qb_map_get(group_map, cpg_group.value);
888 pcd = (
struct confchg_data *)calloc(1,
sizeof(
struct confchg_data));
889 memcpy(&pcd->cpg_group, &cpg_group,
sizeof(
struct cpg_name));
890 qb_map_put(group_map, pcd->cpg_group.value, pcd);
892 size = pcd->left_list_entries;
893 pcd->left_list[size].nodeid = left_pi->
nodeid;
894 pcd->left_list[size].pid = left_pi->
pid;
896 pcd->left_list_entries++;
897 list_del (&left_pi->
list);
903 miter = qb_map_iter_create(group_map);
904 while (qb_map_iter_next(miter, (
void **)&pcd)) {
905 marshall_to_mar_cpg_name_t(&group, &pcd->cpg_group);
907 log_printf (LOG_DEBUG,
"left_list_entries:%d", pcd->left_list_entries);
908 for (i=0; i<pcd->left_list_entries; i++) {
909 log_printf (LOG_DEBUG,
"left_list[%d] group:%s, ip:%s, pid:%d",
910 i, cpg_print_group_name(&group),
912 pcd->left_list[i].pid);
916 notify_lib_joinlist(&group, NULL,
918 pcd->left_list_entries,
924 qb_map_iter_free(miter);
925 qb_map_destroy(group_map);
928 static void joinlist_inform_clients (
void)
935 for (iter = joinlist_messages_head.
next;
936 iter != &joinlist_messages_head;
941 log_printf (LOG_DEBUG,
"joinlist_messages[%u] group:%s, ip:%s, pid:%d",
942 i++, cpg_print_group_name(&stored_msg->
group_name),
956 static void downlist_messages_delete (
void)
961 for (iter = downlist_messages_head.
next;
962 iter != &downlist_messages_head;
965 iter_next = iter->
next;
968 list_del (&stored_msg->
list);
973 static void joinlist_messages_delete (
void)
978 for (iter = joinlist_messages_head.
next;
979 iter != &joinlist_messages_head;
982 iter_next = iter->
next;
985 list_del (&stored_msg->
list);
988 list_init (&joinlist_messages_head);
993 list_init (&downlist_messages_head);
994 list_init (&joinlist_messages_head);
1008 iter_next = iter->
next;
1011 list_del (&pi->
list);
1015 list_del (&cpg_iteration_instance->
list);
1016 hdb_handle_destroy (&cpg_iteration_handle_t_db, cpg_iteration_instance->
handle);
1019 static void cpg_pd_finalize (
struct cpg_pd *cpd)
1022 struct cpg_iteration_instance *cpii;
1029 iter_next = iter->
next;
1033 cpg_iteration_instance_finalize (cpii);
1036 list_del (&cpd->
list);
1039 static int cpg_lib_exit_fn (
void *conn)
1050 cpg_pd_finalize (cpd);
1056 static int cpg_node_joinleave_send (
unsigned int pid,
const mar_cpg_name_t *group_name,
int fn,
int reason)
1059 struct iovec req_exec_cpg_iovec;
1078 static void exec_cpg_procjoin_endian_convert (
void *msg)
1082 req_exec_cpg_procjoin->pid =
swab32(req_exec_cpg_procjoin->pid);
1083 swab_mar_cpg_name_t (&req_exec_cpg_procjoin->group_name);
1084 req_exec_cpg_procjoin->reason =
swab32(req_exec_cpg_procjoin->reason);
1087 static void exec_cpg_joinlist_endian_convert (
void *msg_v)
1090 struct qb_ipc_response_header *res = (
struct qb_ipc_response_header *)msg;
1093 swab_mar_int32_t (&res->size);
1095 while ((
const char*)jle < msg + res->size) {
1102 static void exec_cpg_downlist_endian_convert_old (
void *msg)
1106 static void exec_cpg_downlist_endian_convert (
void *msg)
1111 req_exec_cpg_downlist->left_nodes =
swab32(req_exec_cpg_downlist->left_nodes);
1112 req_exec_cpg_downlist->old_members =
swab32(req_exec_cpg_downlist->old_members);
1114 for (i = 0; i < req_exec_cpg_downlist->left_nodes; i++) {
1115 req_exec_cpg_downlist->nodeids[i] =
swab32(req_exec_cpg_downlist->nodeids[i]);
1120 static void exec_cpg_mcast_endian_convert (
void *msg)
1124 swab_coroipc_request_header_t (&req_exec_cpg_mcast->header);
1125 swab_mar_cpg_name_t (&req_exec_cpg_mcast->group_name);
1126 req_exec_cpg_mcast->pid =
swab32(req_exec_cpg_mcast->pid);
1127 req_exec_cpg_mcast->msglen =
swab32(req_exec_cpg_mcast->msglen);
1128 swab_mar_message_source_t (&req_exec_cpg_mcast->source);
1134 for (iter = process_info_list_head.
next; iter != &process_info_list_head; ) {
1138 if (pi->
pid == pid && pi->
nodeid == nodeid &&
1139 mar_name_compare (&pi->
group, group_name) == 0) {
1147 static void do_proc_join(
1150 unsigned int nodeid,
1159 if (process_info_find (name, pid, nodeid) != NULL) {
1169 memcpy(&pi->
group, name,
sizeof(*name));
1170 list_init(&pi->
list);
1175 list_to_add = &process_info_list_head;
1176 for (list = process_info_list_head.
next; list != &process_info_list_head; list = list->
next) {
1186 list_add (&pi->
list, list_to_add);
1188 notify_info.pid = pi->
pid;
1189 notify_info.nodeid =
nodeid;
1190 notify_info.reason = reason;
1192 notify_lib_joinlist(&pi->
group, NULL,
1198 static void message_handler_req_exec_cpg_downlist_old (
1199 const void *message,
1200 unsigned int nodeid)
1206 static void message_handler_req_exec_cpg_downlist(
1207 const void *message,
1208 unsigned int nodeid)
1210 const struct req_exec_cpg_downlist *req_exec_cpg_downlist = message;
1218 req_exec_cpg_downlist->left_nodes, downlist_state);
1224 stored_msg->old_members = req_exec_cpg_downlist->old_members;
1225 stored_msg->left_nodes = req_exec_cpg_downlist->left_nodes;
1226 memcpy (stored_msg->nodeids, req_exec_cpg_downlist->nodeids,
1227 req_exec_cpg_downlist->left_nodes * sizeof (
mar_uint32_t));
1228 list_init (&stored_msg->
list);
1229 list_add (&stored_msg->
list, &downlist_messages_head);
1231 for (i = 0; i < my_member_list_entries; i++) {
1233 for (iter = downlist_messages_head.
next;
1234 iter != &downlist_messages_head;
1235 iter = iter->
next) {
1247 downlist_master_choose_and_send ();
1251 static void message_handler_req_exec_cpg_procjoin (
1252 const void *message,
1253 unsigned int nodeid)
1260 (
unsigned int)req_exec_cpg_procjoin->pid);
1262 do_proc_join (&req_exec_cpg_procjoin->group_name,
1263 req_exec_cpg_procjoin->pid, nodeid,
1267 static void message_handler_req_exec_cpg_procleave (
1268 const void *message,
1269 unsigned int nodeid)
1278 notify_info.pid = req_exec_cpg_procjoin->pid;
1279 notify_info.nodeid =
nodeid;
1280 notify_info.reason = req_exec_cpg_procjoin->reason;
1282 notify_lib_joinlist(&req_exec_cpg_procjoin->group_name, NULL,
1287 for (iter = process_info_list_head.
next; iter != &process_info_list_head; ) {
1291 if (pi->
pid == req_exec_cpg_procjoin->pid && pi->
nodeid == nodeid &&
1292 mar_name_compare (&pi->
group, &req_exec_cpg_procjoin->group_name)==0) {
1293 list_del (&pi->
list);
1301 static void message_handler_req_exec_cpg_joinlist (
1302 const void *message_v,
1303 unsigned int nodeid)
1305 const char *message = message_v;
1306 const struct qb_ipc_response_header *res = (
const struct qb_ipc_response_header *)message;
1313 while ((
const char*)jle < message + res->size) {
1317 stored_msg->
pid = jle->
pid;
1319 list_init (&stored_msg->
list);
1320 list_add (&stored_msg->
list, &joinlist_messages_head);
1325 static void message_handler_req_exec_cpg_mcast (
1326 const void *message,
1327 unsigned int nodeid)
1331 int msglen = req_exec_cpg_mcast->msglen;
1334 struct iovec iovec[2];
1348 iovec[1].iov_base = (
char*)message+
sizeof(*req_exec_cpg_mcast);
1349 iovec[1].iov_len = msglen;
1351 for (iter = cpg_pd_list_head.
next; iter != &cpg_pd_list_head; ) {
1356 && (mar_name_compare (&cpd->
group_name, &req_exec_cpg_mcast->group_name) == 0)) {
1360 for (pi_iter = process_info_list_head.
next;
1361 pi_iter != &process_info_list_head; pi_iter = pi_iter->
next) {
1365 if (pi->
nodeid == nodeid &&
1366 mar_name_compare (&pi->
group, &req_exec_cpg_mcast->group_name) == 0) {
1384 static int cpg_exec_send_downlist(
void)
1389 g_req_exec_cpg_downlist.header.size =
sizeof(
struct req_exec_cpg_downlist);
1391 g_req_exec_cpg_downlist.old_members = my_old_member_list_entries;
1393 iov.iov_base = (
void *)&g_req_exec_cpg_downlist;
1394 iov.iov_len = g_req_exec_cpg_downlist.header.size;
1399 static int cpg_exec_send_joinlist(
void)
1403 struct qb_ipc_response_header *res;
1406 struct iovec req_exec_cpg_iovec;
1408 for (iter = process_info_list_head.
next; iter != &process_info_list_head; iter = iter->
next) {
1420 buf = alloca(
sizeof(
struct qb_ipc_response_header) +
sizeof(
struct join_list_entry) * count);
1426 jle = (
struct join_list_entry *)(buf +
sizeof(
struct qb_ipc_response_header));
1427 res = (
struct qb_ipc_response_header *)buf;
1429 for (iter = process_info_list_head.
next; iter != &process_info_list_head; iter = iter->
next) {
1440 res->size =
sizeof(
struct qb_ipc_response_header)+sizeof(struct
join_list_entry) * count;
1442 req_exec_cpg_iovec.iov_base = buf;
1443 req_exec_cpg_iovec.iov_len = res->size;
1448 static int cpg_lib_init_fn (
void *conn)
1451 memset (cpd, 0,
sizeof(
struct cpg_pd));
1453 list_add (&cpd->
list, &cpg_pd_list_head);
1464 static void message_handler_req_lib_cpg_join (
void *conn,
const void *message)
1473 for (iter = cpg_pd_list_head.
next; iter != &cpg_pd_list_head; iter = iter->
next) {
1476 if (cpd_item->
pid == req_lib_cpg_join->pid &&
1477 mar_name_compare(&req_lib_cpg_join->group_name, &cpd_item->
group_name) == 0) {
1489 for (iter = process_info_list_head.
next; iter != &process_info_list_head; iter = iter->
next) {
1493 mar_name_compare(&req_lib_cpg_join->group_name, &pi->
group) == 0) {
1509 cpd->
pid = req_lib_cpg_join->pid;
1510 cpd->
flags = req_lib_cpg_join->flags;
1511 memcpy (&cpd->
group_name, &req_lib_cpg_join->group_name,
1514 cpg_node_joinleave_send (req_lib_cpg_join->pid,
1515 &req_lib_cpg_join->group_name,
1537 static void message_handler_req_lib_cpg_leave (
void *conn,
const void *message)
1559 cpg_node_joinleave_send (req_lib_cpg_leave->pid,
1560 &req_lib_cpg_leave->group_name,
1574 static void message_handler_req_lib_cpg_finalize (
1576 const void *message)
1588 list_del (&cpd->
list);
1589 list_init (&cpd->
list);
1609 fd = open (path, O_RDWR, 0600);
1617 res = ftruncate (fd, bytes);
1619 goto error_close_unlink;
1622 addr = mmap (NULL, bytes, PROT_READ | PROT_WRITE,
1625 if (addr == MAP_FAILED) {
1626 goto error_close_unlink;
1629 madvise(addr, bytes, MADV_NOSYNC);
1645 static inline int zcb_alloc (
1647 const char *path_to_file,
1654 zcb_mapped = malloc (
sizeof (
struct zcb_mapped));
1655 if (zcb_mapped == NULL) {
1668 list_init (&zcb_mapped->
list);
1676 static inline int zcb_free (
struct zcb_mapped *zcb_mapped)
1680 res = munmap (zcb_mapped->
addr, zcb_mapped->
size);
1681 list_del (&zcb_mapped->
list);
1686 static inline int zcb_by_addr_free (
struct cpg_pd *cpd,
void *addr)
1689 struct zcb_mapped *zcb_mapped;
1690 unsigned int res = 0;
1695 zcb_mapped =
list_entry (list,
struct zcb_mapped, list);
1697 if (zcb_mapped->
addr == addr) {
1698 res = zcb_free (zcb_mapped);
1706 static inline int zcb_all_free (
1710 struct zcb_mapped *zcb_mapped;
1715 zcb_mapped =
list_entry (list,
struct zcb_mapped, list);
1719 zcb_free (zcb_mapped);
1729 static uint64_t void2serveraddr (
void *server_ptr)
1737 static void *serveraddr2void (uint64_t
server_addr)
1745 static void message_handler_req_lib_cpg_zc_alloc (
1747 const void *message)
1750 struct qb_ipc_response_header res_header;
1758 res = zcb_alloc (cpd, hdr->path_to_file, hdr->map_size,
1765 res_header.size =
sizeof (
struct qb_ipc_response_header);
1772 static void message_handler_req_lib_cpg_zc_free (
1774 const void *message)
1777 struct qb_ipc_response_header res_header;
1783 addr = serveraddr2void (hdr->server_address);
1785 zcb_by_addr_free (cpd, addr);
1787 res_header.size =
sizeof (
struct qb_ipc_response_header);
1795 static void message_handler_req_lib_cpg_mcast (
void *conn,
const void *message)
1801 struct iovec req_exec_cpg_iovec[2];
1802 struct req_exec_cpg_mcast req_exec_cpg_mcast;
1803 int msglen = req_lib_cpg_mcast->msglen;
1824 if (error ==
CS_OK) {
1825 req_exec_cpg_mcast.header.size =
sizeof(req_exec_cpg_mcast) + msglen;
1828 req_exec_cpg_mcast.pid = cpd->
pid;
1829 req_exec_cpg_mcast.msglen = msglen;
1831 memcpy(&req_exec_cpg_mcast.group_name, &group_name,
1834 req_exec_cpg_iovec[0].iov_base = (
char *)&req_exec_cpg_mcast;
1835 req_exec_cpg_iovec[0].iov_len =
sizeof(req_exec_cpg_mcast);
1836 req_exec_cpg_iovec[1].iov_base = (
char *)&req_lib_cpg_mcast->message;
1837 req_exec_cpg_iovec[1].iov_len = msglen;
1840 assert(result == 0);
1843 conn, group_name.value, cpd->
cpd_state, error);
1847 static void message_handler_req_lib_cpg_zc_execute (
1849 const void *message)
1852 struct qb_ipc_request_header *
header;
1855 struct iovec req_exec_cpg_iovec[2];
1856 struct req_exec_cpg_mcast req_exec_cpg_mcast;
1857 struct req_lib_cpg_mcast *req_lib_cpg_mcast;
1863 header = (
struct qb_ipc_request_header *)(((
char *)serveraddr2void(hdr->server_address) + sizeof (
struct coroipcs_zc_header)));
1864 req_lib_cpg_mcast = (
struct req_lib_cpg_mcast *)header;
1883 if (error ==
CS_OK) {
1884 req_exec_cpg_mcast.header.size =
sizeof(req_exec_cpg_mcast) + req_lib_cpg_mcast->msglen;
1887 req_exec_cpg_mcast.pid = cpd->
pid;
1888 req_exec_cpg_mcast.msglen = req_lib_cpg_mcast->msglen;
1890 memcpy(&req_exec_cpg_mcast.group_name, &cpd->
group_name,
1893 req_exec_cpg_iovec[0].iov_base = (
char *)&req_exec_cpg_mcast;
1894 req_exec_cpg_iovec[0].iov_len =
sizeof(req_exec_cpg_mcast);
1895 req_exec_cpg_iovec[1].iov_base = (
char *)header +
sizeof(
struct req_lib_cpg_mcast);
1896 req_exec_cpg_iovec[1].iov_len = req_exec_cpg_mcast.msglen;
1913 static void message_handler_req_lib_cpg_membership (
void *conn,
1914 const void *message)
1917 (
struct req_lib_cpg_membership_get *)message;
1920 int member_count = 0;
1927 for (iter = process_info_list_head.
next;
1928 iter != &process_info_list_head; iter = iter->
next) {
1931 if (mar_name_compare (&pi->
group, &req_lib_cpg_membership_get->group_name) == 0) {
1943 static void message_handler_req_lib_cpg_local_get (
void *conn,
1944 const void *message)
1957 static void message_handler_req_lib_cpg_iteration_initialize (
1959 const void *message)
1966 struct cpg_iteration_instance *cpg_iteration_instance;
1979 res = hdb_handle_create (&cpg_iteration_handle_t_db,
sizeof (
struct cpg_iteration_instance),
1980 &cpg_iteration_handle);
1987 res = hdb_handle_get (&cpg_iteration_handle_t_db, cpg_iteration_handle, (
void *)&cpg_iteration_instance);
1995 cpg_iteration_instance->
handle = cpg_iteration_handle;
2000 for (iter = process_info_list_head.
next; iter != &process_info_list_head; iter = iter->
next) {
2012 iter2 = iter2->
next) {
2015 if (mar_name_compare (&pi2->
group, &pi->
group) == 0) {
2031 if (mar_name_compare (&pi->
group, &req_lib_cpg_iterationinitialize->group_name) != 0)
2044 goto error_put_destroy;
2048 list_init (&new_pi->
list);
2062 iter2 = iter2->
next) {
2065 if (mar_name_compare (&pi2->
group, &pi->
group) == 0) {
2070 list_add (&new_pi->
list, iter2);
2080 list_init (&cpg_iteration_instance->
list);
2086 hdb_handle_put (&cpg_iteration_handle_t_db, cpg_iteration_handle);
2088 if (error !=
CS_OK) {
2089 hdb_handle_destroy (&cpg_iteration_handle_t_db, cpg_iteration_handle);
2102 static void message_handler_req_lib_cpg_iteration_next (
2104 const void *message)
2108 struct cpg_iteration_instance *cpg_iteration_instance;
2115 res = hdb_handle_get (&cpg_iteration_handle_t_db,
2116 req_lib_cpg_iterationnext->iteration_handle,
2117 (
void *)&cpg_iteration_instance);
2124 assert (cpg_iteration_instance);
2145 hdb_handle_put (&cpg_iteration_handle_t_db, req_lib_cpg_iterationnext->iteration_handle);
2155 static void message_handler_req_lib_cpg_iteration_finalize (
2157 const void *message)
2161 struct cpg_iteration_instance *cpg_iteration_instance;
2167 res = hdb_handle_get (&cpg_iteration_handle_t_db,
2168 req_lib_cpg_iterationfinalize->iteration_handle,
2169 (
void *)&cpg_iteration_instance);
2176 assert (cpg_iteration_instance);
2178 cpg_iteration_instance_finalize (cpg_iteration_instance);
2179 hdb_handle_put (&cpg_iteration_handle_t_db, cpg_iteration_instance->
handle);
int initial_totem_conf_sent
mar_cpg_address_t member_list[]
mar_uint32_t sender_nodeid
#define CPG_MAX_NAME_LENGTH
void(* lib_handler_fn)(void *conn, const void *msg)
#define LOGSYS_LEVEL_TRACE
mar_uint32_t sender_nodeid
#define CPG_MODEL_V1_DELIVER_INITIAL_TOTEM_CONF
mar_uint32_t old_members __attribute__((aligned(8)))
struct corosync_service_engine * cpg_get_service_engine_ver0(void)
struct message_header header
struct list_head * current_pointer
unsigned char addr[TOTEMIP_ADDRLEN]
struct qb_ipc_request_header header __attribute__((aligned(8)))
struct qb_ipc_request_header header __attribute__((aligned(8)))
#define log_printf(level, format, args...)
void(* exec_handler_fn)(const void *msg, unsigned int nodeid)
struct list_head iteration_instance_list_head
#define SERVICE_ID_MAKE(a, b)
#define LOGSYS_LEVEL_WARNING
void *(* ipc_private_data_get)(void *conn)
#define LOGSYS_DECLARE_SUBSYS(subsys)
void(* ipc_source_set)(mar_message_source_t *source, void *conn)
void(* ipc_refcnt_inc)(void *conn)
#define LOGSYS_LEVEL_ERROR
void(* ipc_refcnt_dec)(void *conn)
struct totem_ip_address rep
mar_uint32_t member_list[]
#define DECLARE_LIST_INIT(name)
#define LOGSYS_LEVEL_DEBUG
mar_cpg_address_t member_list[PROCESSOR_COUNT_MAX]
int(* ipc_dispatch_iov_send)(void *conn, const struct iovec *iov, unsigned int iov_len)
mar_cpg_name_t group_name
mar_cpg_name_t group_name
int(* ipc_dispatch_send)(void *conn, const void *msg, size_t mlen)
int(* totem_mcast)(const struct iovec *iovec, unsigned int iov_len, unsigned int guarantee)
int(* ipc_response_send)(void *conn, const void *msg, size_t mlen)
#define PROCESSOR_COUNT_MAX
struct corosync_service_engine cpg_service_engine
struct list_head zcb_mapped_list_head
#define DECLARE_HDB_DATABASE
struct qb_ipc_request_header header __attribute__((aligned(8)))
#define list_entry(ptr, type, member)
mar_cpg_name_t group_name
struct list_head items_list_head
struct memb_ring_id ring_id
const char *(* totem_ifaces_print)(unsigned int nodeid)
struct qb_ipc_request_header header __attribute__((aligned(8)))
unsigned int(* totem_nodeid_get)(void)
Message from another node.