|
|
0240e4 |
From 6239d1dd84a50585a30175978be7e6d8ffb0b155 Mon Sep 17 00:00:00 2001
|
|
|
0240e4 |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
0240e4 |
Date: Tue, 22 Dec 2015 15:59:21 -0600
|
|
|
0240e4 |
Subject: [PATCH 102/105] Refactor: crmd,lrmd,liblrmd: use defined constants
|
|
|
0240e4 |
for lrmd IPC operations
|
|
|
0240e4 |
|
|
|
0240e4 |
Reduces chance of typos.
|
|
|
0240e4 |
---
|
|
|
0240e4 |
crmd/lrm_state.c | 6 +++---
|
|
|
0240e4 |
include/crm/lrmd.h | 6 ++++++
|
|
|
0240e4 |
lib/lrmd/proxy_common.c | 6 +++---
|
|
|
0240e4 |
lrmd/ipc_proxy.c | 14 +++++++-------
|
|
|
0240e4 |
lrmd/remote_ctl.c | 6 +++---
|
|
|
0240e4 |
5 files changed, 22 insertions(+), 16 deletions(-)
|
|
|
0240e4 |
|
|
|
0240e4 |
diff --git a/crmd/lrm_state.c b/crmd/lrm_state.c
|
|
|
0240e4 |
index 0e52ff6..497d3f9 100644
|
|
|
0240e4 |
--- a/crmd/lrm_state.c
|
|
|
0240e4 |
+++ b/crmd/lrm_state.c
|
|
|
0240e4 |
@@ -481,7 +481,7 @@ remote_proxy_cb(lrmd_t *lrmd, void *userdata, xmlNode *msg)
|
|
|
0240e4 |
crm_element_value_int(msg, F_LRMD_IPC_MSG_ID, &msg_id);
|
|
|
0240e4 |
|
|
|
0240e4 |
/* This is msg from remote ipc client going to real ipc server */
|
|
|
0240e4 |
- if (safe_str_eq(op, "new")) {
|
|
|
0240e4 |
+ if (safe_str_eq(op, LRMD_IPC_OP_NEW)) {
|
|
|
0240e4 |
const char *channel = crm_element_value(msg, F_LRMD_IPC_IPC_SERVER);
|
|
|
0240e4 |
|
|
|
0240e4 |
CRM_CHECK(channel != NULL, return);
|
|
|
0240e4 |
@@ -490,10 +490,10 @@ remote_proxy_cb(lrmd_t *lrmd, void *userdata, xmlNode *msg)
|
|
|
0240e4 |
remote_proxy_notify_destroy(lrmd, session);
|
|
|
0240e4 |
}
|
|
|
0240e4 |
crm_trace("new remote proxy client established to %s, session id %s", channel, session);
|
|
|
0240e4 |
- } else if (safe_str_eq(op, "destroy")) {
|
|
|
0240e4 |
+ } else if (safe_str_eq(op, LRMD_IPC_OP_DESTROY)) {
|
|
|
0240e4 |
remote_proxy_end_session(session);
|
|
|
0240e4 |
|
|
|
0240e4 |
- } else if (safe_str_eq(op, "request")) {
|
|
|
0240e4 |
+ } else if (safe_str_eq(op, LRMD_IPC_OP_REQUEST)) {
|
|
|
0240e4 |
int flags = 0;
|
|
|
0240e4 |
xmlNode *request = get_message_xml(msg, F_LRMD_IPC_MSG);
|
|
|
0240e4 |
const char *name = crm_element_value(msg, F_LRMD_IPC_CLIENT);
|
|
|
0240e4 |
diff --git a/include/crm/lrmd.h b/include/crm/lrmd.h
|
|
|
0240e4 |
index 5a3c6ce..5c74798 100644
|
|
|
0240e4 |
--- a/include/crm/lrmd.h
|
|
|
0240e4 |
+++ b/include/crm/lrmd.h
|
|
|
0240e4 |
@@ -90,6 +90,12 @@ typedef struct lrmd_key_value_s {
|
|
|
0240e4 |
#define LRMD_OP_POKE "lrmd_rsc_poke"
|
|
|
0240e4 |
#define LRMD_OP_NEW_CLIENT "lrmd_rsc_new_client"
|
|
|
0240e4 |
|
|
|
0240e4 |
+#define LRMD_IPC_OP_NEW "new"
|
|
|
0240e4 |
+#define LRMD_IPC_OP_DESTROY "destroy"
|
|
|
0240e4 |
+#define LRMD_IPC_OP_EVENT "event"
|
|
|
0240e4 |
+#define LRMD_IPC_OP_REQUEST "request"
|
|
|
0240e4 |
+#define LRMD_IPC_OP_RESPONSE "response"
|
|
|
0240e4 |
+
|
|
|
0240e4 |
#define F_LRMD_IPC_OP "lrmd_ipc_op"
|
|
|
0240e4 |
#define F_LRMD_IPC_IPC_SERVER "lrmd_ipc_server"
|
|
|
0240e4 |
#define F_LRMD_IPC_SESSION "lrmd_ipc_session"
|
|
|
0240e4 |
diff --git a/lib/lrmd/proxy_common.c b/lib/lrmd/proxy_common.c
|
|
|
0240e4 |
index 50c59c3..a0f5e62 100644
|
|
|
0240e4 |
--- a/lib/lrmd/proxy_common.c
|
|
|
0240e4 |
+++ b/lib/lrmd/proxy_common.c
|
|
|
0240e4 |
@@ -39,7 +39,7 @@ remote_proxy_notify_destroy(lrmd_t *lrmd, const char *session_id)
|
|
|
0240e4 |
{
|
|
|
0240e4 |
/* sending to the remote node that an ipc connection has been destroyed */
|
|
|
0240e4 |
xmlNode *msg = create_xml_node(NULL, T_LRMD_IPC_PROXY);
|
|
|
0240e4 |
- crm_xml_add(msg, F_LRMD_IPC_OP, "destroy");
|
|
|
0240e4 |
+ crm_xml_add(msg, F_LRMD_IPC_OP, LRMD_IPC_OP_DESTROY);
|
|
|
0240e4 |
crm_xml_add(msg, F_LRMD_IPC_SESSION, session_id);
|
|
|
0240e4 |
lrmd_internal_proxy_send(lrmd, msg);
|
|
|
0240e4 |
free_xml(msg);
|
|
|
0240e4 |
@@ -50,7 +50,7 @@ remote_proxy_relay_event(lrmd_t *lrmd, const char *session_id, xmlNode *msg)
|
|
|
0240e4 |
{
|
|
|
0240e4 |
/* sending to the remote node an event msg. */
|
|
|
0240e4 |
xmlNode *event = create_xml_node(NULL, T_LRMD_IPC_PROXY);
|
|
|
0240e4 |
- crm_xml_add(event, F_LRMD_IPC_OP, "event");
|
|
|
0240e4 |
+ crm_xml_add(event, F_LRMD_IPC_OP, LRMD_IPC_OP_EVENT);
|
|
|
0240e4 |
crm_xml_add(event, F_LRMD_IPC_SESSION, session_id);
|
|
|
0240e4 |
add_message_xml(event, F_LRMD_IPC_MSG, msg);
|
|
|
0240e4 |
crm_log_xml_explicit(event, "EventForProxy");
|
|
|
0240e4 |
@@ -63,7 +63,7 @@ remote_proxy_relay_response(lrmd_t *lrmd, const char *session_id, xmlNode *msg,
|
|
|
0240e4 |
{
|
|
|
0240e4 |
/* sending to the remote node a response msg. */
|
|
|
0240e4 |
xmlNode *response = create_xml_node(NULL, T_LRMD_IPC_PROXY);
|
|
|
0240e4 |
- crm_xml_add(response, F_LRMD_IPC_OP, "response");
|
|
|
0240e4 |
+ crm_xml_add(response, F_LRMD_IPC_OP, LRMD_IPC_OP_RESPONSE);
|
|
|
0240e4 |
crm_xml_add(response, F_LRMD_IPC_SESSION, session_id);
|
|
|
0240e4 |
crm_xml_add_int(response, F_LRMD_IPC_MSG_ID, msg_id);
|
|
|
0240e4 |
add_message_xml(response, F_LRMD_IPC_MSG, msg);
|
|
|
0240e4 |
diff --git a/lrmd/ipc_proxy.c b/lrmd/ipc_proxy.c
|
|
|
0240e4 |
index d95a396..164a9ff 100644
|
|
|
0240e4 |
--- a/lrmd/ipc_proxy.c
|
|
|
0240e4 |
+++ b/lrmd/ipc_proxy.c
|
|
|
0240e4 |
@@ -101,7 +101,7 @@ ipc_proxy_accept(qb_ipcs_connection_t * c, uid_t uid, gid_t gid, const char *ipc
|
|
|
0240e4 |
g_hash_table_insert(ipc_clients, client->id, client);
|
|
|
0240e4 |
|
|
|
0240e4 |
msg = create_xml_node(NULL, T_LRMD_IPC_PROXY);
|
|
|
0240e4 |
- crm_xml_add(msg, F_LRMD_IPC_OP, "new");
|
|
|
0240e4 |
+ crm_xml_add(msg, F_LRMD_IPC_OP, LRMD_IPC_OP_NEW);
|
|
|
0240e4 |
crm_xml_add(msg, F_LRMD_IPC_IPC_SERVER, ipc_channel);
|
|
|
0240e4 |
crm_xml_add(msg, F_LRMD_IPC_SESSION, client->id);
|
|
|
0240e4 |
lrmd_server_send_notify(ipc_proxy, msg);
|
|
|
0240e4 |
@@ -157,7 +157,7 @@ ipc_proxy_forward_client(crm_client_t *ipc_proxy, xmlNode *xml)
|
|
|
0240e4 |
|
|
|
0240e4 |
if (ipc_client == NULL) {
|
|
|
0240e4 |
xmlNode *msg = create_xml_node(NULL, T_LRMD_IPC_PROXY);
|
|
|
0240e4 |
- crm_xml_add(msg, F_LRMD_IPC_OP, "destroy");
|
|
|
0240e4 |
+ crm_xml_add(msg, F_LRMD_IPC_OP, LRMD_IPC_OP_DESTROY);
|
|
|
0240e4 |
crm_xml_add(msg, F_LRMD_IPC_SESSION, session);
|
|
|
0240e4 |
lrmd_server_send_notify(ipc_proxy, msg);
|
|
|
0240e4 |
free_xml(msg);
|
|
|
0240e4 |
@@ -176,11 +176,11 @@ ipc_proxy_forward_client(crm_client_t *ipc_proxy, xmlNode *xml)
|
|
|
0240e4 |
* and forwarding it to connection 1.
|
|
|
0240e4 |
*/
|
|
|
0240e4 |
|
|
|
0240e4 |
- if (safe_str_eq(msg_type, "event")) {
|
|
|
0240e4 |
+ if (safe_str_eq(msg_type, LRMD_IPC_OP_EVENT)) {
|
|
|
0240e4 |
crm_trace("Sending event to %s", ipc_client->id);
|
|
|
0240e4 |
rc = crm_ipcs_send(ipc_client, 0, msg, crm_ipc_server_event);
|
|
|
0240e4 |
|
|
|
0240e4 |
- } else if (safe_str_eq(msg_type, "response")) {
|
|
|
0240e4 |
+ } else if (safe_str_eq(msg_type, LRMD_IPC_OP_RESPONSE)) {
|
|
|
0240e4 |
int msg_id = 0;
|
|
|
0240e4 |
|
|
|
0240e4 |
crm_element_value_int(xml, F_LRMD_IPC_MSG_ID, &msg_id);
|
|
|
0240e4 |
@@ -190,7 +190,7 @@ ipc_proxy_forward_client(crm_client_t *ipc_proxy, xmlNode *xml)
|
|
|
0240e4 |
CRM_LOG_ASSERT(msg_id == ipc_client->request_id);
|
|
|
0240e4 |
ipc_client->request_id = 0;
|
|
|
0240e4 |
|
|
|
0240e4 |
- } else if (safe_str_eq(msg_type, "destroy")) {
|
|
|
0240e4 |
+ } else if (safe_str_eq(msg_type, LRMD_IPC_OP_DESTROY)) {
|
|
|
0240e4 |
qb_ipcs_disconnect(ipc_client->ipcs);
|
|
|
0240e4 |
|
|
|
0240e4 |
} else {
|
|
|
0240e4 |
@@ -245,7 +245,7 @@ ipc_proxy_dispatch(qb_ipcs_connection_t * c, void *data, size_t size)
|
|
|
0240e4 |
client->request_id = id;
|
|
|
0240e4 |
|
|
|
0240e4 |
msg = create_xml_node(NULL, T_LRMD_IPC_PROXY);
|
|
|
0240e4 |
- crm_xml_add(msg, F_LRMD_IPC_OP, "request");
|
|
|
0240e4 |
+ crm_xml_add(msg, F_LRMD_IPC_OP, LRMD_IPC_OP_REQUEST);
|
|
|
0240e4 |
crm_xml_add(msg, F_LRMD_IPC_SESSION, client->id);
|
|
|
0240e4 |
crm_xml_add(msg, F_LRMD_IPC_CLIENT, crm_client_name(client));
|
|
|
0240e4 |
crm_xml_add(msg, F_LRMD_IPC_USER, client->user);
|
|
|
0240e4 |
@@ -275,7 +275,7 @@ ipc_proxy_closed(qb_ipcs_connection_t * c)
|
|
|
0240e4 |
|
|
|
0240e4 |
if (ipc_proxy) {
|
|
|
0240e4 |
xmlNode *msg = create_xml_node(NULL, T_LRMD_IPC_PROXY);
|
|
|
0240e4 |
- crm_xml_add(msg, F_LRMD_IPC_OP, "destroy");
|
|
|
0240e4 |
+ crm_xml_add(msg, F_LRMD_IPC_OP, LRMD_IPC_OP_DESTROY);
|
|
|
0240e4 |
crm_xml_add(msg, F_LRMD_IPC_SESSION, client->id);
|
|
|
0240e4 |
lrmd_server_send_notify(ipc_proxy, msg);
|
|
|
0240e4 |
free_xml(msg);
|
|
|
0240e4 |
diff --git a/lrmd/remote_ctl.c b/lrmd/remote_ctl.c
|
|
|
0240e4 |
index ad85954..1983c88 100644
|
|
|
0240e4 |
--- a/lrmd/remote_ctl.c
|
|
|
0240e4 |
+++ b/lrmd/remote_ctl.c
|
|
|
0240e4 |
@@ -333,7 +333,7 @@ remote_proxy_cb(lrmd_t *lrmd, void *userdata, xmlNode *msg)
|
|
|
0240e4 |
crm_element_value_int(msg, F_LRMD_IPC_MSG_ID, &msg_id);
|
|
|
0240e4 |
|
|
|
0240e4 |
/* This is msg from remote ipc client going to real ipc server */
|
|
|
0240e4 |
- if (safe_str_eq(op, "new")) {
|
|
|
0240e4 |
+ if (safe_str_eq(op, LRMD_IPC_OP_NEW)) {
|
|
|
0240e4 |
const char *channel = crm_element_value(msg, F_LRMD_IPC_IPC_SERVER);
|
|
|
0240e4 |
|
|
|
0240e4 |
CRM_CHECK(channel != NULL, return);
|
|
|
0240e4 |
@@ -342,10 +342,10 @@ remote_proxy_cb(lrmd_t *lrmd, void *userdata, xmlNode *msg)
|
|
|
0240e4 |
remote_proxy_notify_destroy(lrmd, session);
|
|
|
0240e4 |
}
|
|
|
0240e4 |
crm_info("new remote proxy client established to %s, session id %s", channel, session);
|
|
|
0240e4 |
- } else if (safe_str_eq(op, "destroy")) {
|
|
|
0240e4 |
+ } else if (safe_str_eq(op, LRMD_IPC_OP_DESTROY)) {
|
|
|
0240e4 |
remote_proxy_end_session(session);
|
|
|
0240e4 |
|
|
|
0240e4 |
- } else if (safe_str_eq(op, "request")) {
|
|
|
0240e4 |
+ } else if (safe_str_eq(op, LRMD_IPC_OP_REQUEST)) {
|
|
|
0240e4 |
int flags = 0;
|
|
|
0240e4 |
xmlNode *request = get_message_xml(msg, F_LRMD_IPC_MSG);
|
|
|
0240e4 |
const char *name = crm_element_value(msg, F_LRMD_IPC_CLIENT);
|
|
|
0240e4 |
--
|
|
|
0240e4 |
1.8.3.1
|
|
|
0240e4 |
|