MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / init_cpg_connection

Function init_cpg_connection

lib/cluster/corosync.c:598–651  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

596};
597
598static gboolean
599init_cpg_connection(gboolean(*dispatch) (int kind, const char *from, const char *data), void (*destroy) (gpointer),
600 uint32_t * nodeid)
601{
602 int rc = -1;
603 int fd = 0;
604 int retries = 0;
605 crm_node_t *peer = NULL;
606 struct mainloop_fd_callbacks cpg_fd_callbacks = {
607 .dispatch = pcmk_cpg_dispatch,
608 .destroy = destroy,
609 };
610
611 strncpy(pcmk_cpg_group.value, crm_system_name, 128);
612 pcmk_cpg_group.length = strlen(crm_system_name) + 1;
613
614 cs_repeat(retries, 30, rc = cpg_initialize(&pcmk_cpg_handle, &cpg_callbacks));
615 if (rc != CS_OK) {
616 crm_err("Could not connect to the Cluster Process Group API: %d\n", rc);
617 goto bail;
618 }
619
620 retries = 0;
621 cs_repeat(retries, 30, rc = cpg_local_get(pcmk_cpg_handle, (unsigned int *)nodeid));
622 if (rc != CS_OK) {
623 crm_err("Could not get local node id from the CPG API");
624 goto bail;
625 }
626
627 retries = 0;
628 cs_repeat(retries, 30, rc = cpg_join(pcmk_cpg_handle, &pcmk_cpg_group));
629 if (rc != CS_OK) {
630 crm_err("Could not join the CPG group '%s': %d", crm_system_name, rc);
631 goto bail;
632 }
633
634 rc = cpg_fd_get(pcmk_cpg_handle, &fd);
635 if (rc != CS_OK) {
636 crm_err("Could not obtain the CPG API connection: %d\n", rc);
637 goto bail;
638 }
639
640 mainloop_add_fd("corosync-cpg", G_PRIORITY_MEDIUM, fd, dispatch, &cpg_fd_callbacks);
641
642 bail:
643 if (rc != CS_OK) {
644 cpg_finalize(pcmk_cpg_handle);
645 return FALSE;
646 }
647
648 peer = crm_get_peer(pcmk_nodeid, pcmk_uname);
649 crm_update_peer_proc(__FUNCTION__, peer, crm_proc_cpg, ONLINESTATUS);
650 return TRUE;
651}
652
653static int
654pcmk_quorum_dispatch(gpointer user_data)

Callers 1

init_cs_connection_onceFunction · 0.70

Calls 3

mainloop_add_fdFunction · 0.85
crm_get_peerFunction · 0.85
crm_update_peer_procFunction · 0.85

Tested by

no test coverage detected