This source file includes following definitions.
- crmd_cs_dispatch
- crmd_quorum_callback
- crmd_cs_destroy
- crm_connect_corosync
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <sys/param.h>
13 #include <sys/types.h>
14 #include <sys/stat.h>
15
16 #include <crm/crm.h>
17 #include <crm/cluster/internal.h>
18 #include <crm/common/xml.h>
19
20 #include <pacemaker-controld.h>
21
22 #if SUPPORT_COROSYNC
23
24 extern void post_cache_update(int seq);
25
26
27
28 static void
29 crmd_cs_dispatch(cpg_handle_t handle, const struct cpg_name *groupName,
30 uint32_t nodeid, uint32_t pid, void *msg, size_t msg_len)
31 {
32 uint32_t kind = 0;
33 const char *from = NULL;
34 char *data = pcmk_message_common_cs(handle, nodeid, pid, msg, &kind, &from);
35
36 if(data == NULL) {
37 return;
38 }
39 if (kind == crm_class_cluster) {
40 crm_node_t *peer = NULL;
41 xmlNode *xml = string2xml(data);
42
43 if (xml == NULL) {
44 crm_err("Could not parse message content (%d): %.100s", kind, data);
45 free(data);
46 return;
47 }
48
49 crm_xml_add(xml, F_ORIG, from);
50
51
52 peer = crm_get_peer(0, from);
53 if (!pcmk_is_set(peer->processes, crm_proc_cpg)) {
54
55
56
57 crm_warn("Receiving messages from a node we think is dead: %s[%d]",
58 peer->uname, peer->id);
59 crm_update_peer_proc(__func__, peer, crm_proc_cpg,
60 ONLINESTATUS);
61 }
62 crmd_ha_msg_filter(xml);
63 free_xml(xml);
64 } else {
65 crm_err("Invalid message class (%d): %.100s", kind, data);
66 }
67 free(data);
68 }
69
70 static gboolean
71 crmd_quorum_callback(unsigned long long seq, gboolean quorate)
72 {
73 crm_update_quorum(quorate, FALSE);
74 post_cache_update(seq);
75 return TRUE;
76 }
77
78 static void
79 crmd_cs_destroy(gpointer user_data)
80 {
81 if (!pcmk_is_set(fsa_input_register, R_HA_DISCONNECTED)) {
82 crm_crit("Lost connection to cluster layer, shutting down");
83 crmd_exit(CRM_EX_DISCONNECT);
84
85 } else {
86 crm_info("Corosync connection closed");
87 }
88 }
89
90 extern gboolean crm_connect_corosync(crm_cluster_t * cluster);
91
92 gboolean
93 crm_connect_corosync(crm_cluster_t * cluster)
94 {
95 if (is_corosync_cluster()) {
96 crm_set_status_callback(&peer_update_callback);
97 cluster->cpg.cpg_deliver_fn = crmd_cs_dispatch;
98 cluster->cpg.cpg_confchg_fn = pcmk_cpg_membership;
99 cluster->destroy = crmd_cs_destroy;
100
101 if (crm_cluster_connect(cluster)) {
102 pcmk__corosync_quorum_connect(crmd_quorum_callback,
103 crmd_cs_destroy);
104 return TRUE;
105 }
106 }
107 return FALSE;
108 }
109
110 #endif