Blame SOURCES/0104-Feature-lrmd-liblrmd-add-lrmd-IPC-operations-for-req.patch

0240e4
From 29cc1018cb98b1ff864f2aed090cb6b591963275 Mon Sep 17 00:00:00 2001
0240e4
From: Ken Gaillot <kgaillot@redhat.com>
0240e4
Date: Wed, 23 Dec 2015 15:01:48 -0600
0240e4
Subject: [PATCH 104/105] Feature: lrmd,liblrmd: add lrmd IPC operations for
0240e4
 requesting and acknowledging shutdown
0240e4
0240e4
This adds two new lrmd IPC operations, LRMD_IPC_OP_SHUTDOWN_REQ and
0240e4
LRMD_IPC_OP_SHUTDOWN_ACK, along with functions to send them.
0240e4
This will support the ability to stop pacemaker_remote gracefully.
0240e4
0240e4
At this point, no code uses these new operations.
0240e4
---
0240e4
 include/crm/lrmd.h      |  2 ++
0240e4
 include/crm_internal.h  |  1 +
0240e4
 lib/lrmd/proxy_common.c | 14 ++++++++++++++
0240e4
 lrmd/ipc_proxy.c        | 24 ++++++++++++++++++++++++
0240e4
 lrmd/lrmd_private.h     |  1 +
0240e4
 5 files changed, 42 insertions(+)
0240e4
0240e4
diff --git a/include/crm/lrmd.h b/include/crm/lrmd.h
0240e4
index 5c74798..6660fb9 100644
0240e4
--- a/include/crm/lrmd.h
0240e4
+++ b/include/crm/lrmd.h
0240e4
@@ -95,6 +95,8 @@ typedef struct lrmd_key_value_s {
0240e4
 #define LRMD_IPC_OP_EVENT         "event"
0240e4
 #define LRMD_IPC_OP_REQUEST       "request"
0240e4
 #define LRMD_IPC_OP_RESPONSE      "response"
0240e4
+#define LRMD_IPC_OP_SHUTDOWN_REQ  "shutdown_req"
0240e4
+#define LRMD_IPC_OP_SHUTDOWN_ACK  "shutdown_ack"
0240e4
 
0240e4
 #define F_LRMD_IPC_OP           "lrmd_ipc_op"
0240e4
 #define F_LRMD_IPC_IPC_SERVER   "lrmd_ipc_server"
0240e4
diff --git a/include/crm_internal.h b/include/crm_internal.h
0240e4
index e0bbb06..c5fbcb7 100644
0240e4
--- a/include/crm_internal.h
0240e4
+++ b/include/crm_internal.h
0240e4
@@ -380,6 +380,7 @@ typedef struct remote_proxy_s {
0240e4
 
0240e4
 } remote_proxy_t;
0240e4
 void remote_proxy_notify_destroy(lrmd_t *lrmd, const char *session_id);
0240e4
+void remote_proxy_ack_shutdown(lrmd_t *lrmd);
0240e4
 void remote_proxy_relay_event(lrmd_t *lrmd, const char *session_id, xmlNode *msg);
0240e4
 void remote_proxy_relay_response(lrmd_t *lrmd, const char *session_id, xmlNode *msg, int msg_id);
0240e4
 void remote_proxy_end_session(const char *session);
0240e4
diff --git a/lib/lrmd/proxy_common.c b/lib/lrmd/proxy_common.c
0240e4
index a0f5e62..eb17e4e 100644
0240e4
--- a/lib/lrmd/proxy_common.c
0240e4
+++ b/lib/lrmd/proxy_common.c
0240e4
@@ -45,6 +45,20 @@ remote_proxy_notify_destroy(lrmd_t *lrmd, const char *session_id)
0240e4
     free_xml(msg);
0240e4
 }
0240e4
 
0240e4
+/*!
0240e4
+ * \brief Send an acknowledgment of a remote proxy shutdown request.
0240e4
+ *
0240e4
+ * \param[in] lrmd  Connection to proxy
0240e4
+ */
0240e4
+void
0240e4
+remote_proxy_ack_shutdown(lrmd_t *lrmd)
0240e4
+{
0240e4
+    xmlNode *msg = create_xml_node(NULL, T_LRMD_IPC_PROXY);
0240e4
+    crm_xml_add(msg, F_LRMD_IPC_OP, LRMD_IPC_OP_SHUTDOWN_ACK);
0240e4
+    lrmd_internal_proxy_send(lrmd, msg);
0240e4
+    free_xml(msg);
0240e4
+}
0240e4
+
0240e4
 void
0240e4
 remote_proxy_relay_event(lrmd_t *lrmd, const char *session_id, xmlNode *msg)
0240e4
 {
0240e4
diff --git a/lrmd/ipc_proxy.c b/lrmd/ipc_proxy.c
0240e4
index 164a9ff..9633a67 100644
0240e4
--- a/lrmd/ipc_proxy.c
0240e4
+++ b/lrmd/ipc_proxy.c
0240e4
@@ -259,6 +259,30 @@ ipc_proxy_dispatch(qb_ipcs_connection_t * c, void *data, size_t size)
0240e4
     return 0;
0240e4
 }
0240e4
 
0240e4
+/*!
0240e4
+ * \internal
0240e4
+ * \brief Notify a proxy provider that we wish to shut down
0240e4
+ *
0240e4
+ * \return 0 on success, -1 on error
0240e4
+ */
0240e4
+int
0240e4
+ipc_proxy_shutdown_req(crm_client_t *ipc_proxy)
0240e4
+{
0240e4
+    xmlNode *msg = create_xml_node(NULL, T_LRMD_IPC_PROXY);
0240e4
+    int rc;
0240e4
+
0240e4
+    crm_xml_add(msg, F_LRMD_IPC_OP, LRMD_IPC_OP_SHUTDOWN_REQ);
0240e4
+
0240e4
+    /* We don't really have a session, but crmd needs this attribute
0240e4
+     * to recognize this as proxy communication.
0240e4
+     */
0240e4
+    crm_xml_add(msg, F_LRMD_IPC_SESSION, "0");
0240e4
+
0240e4
+    rc = (lrmd_server_send_notify(ipc_proxy, msg) < 0)? -1 : 0;
0240e4
+    free_xml(msg);
0240e4
+    return rc;
0240e4
+}
0240e4
+
0240e4
 static int32_t
0240e4
 ipc_proxy_closed(qb_ipcs_connection_t * c)
0240e4
 {
0240e4
diff --git a/lrmd/lrmd_private.h b/lrmd/lrmd_private.h
0240e4
index 52f79b8..78f14c9 100644
0240e4
--- a/lrmd/lrmd_private.h
0240e4
+++ b/lrmd/lrmd_private.h
0240e4
@@ -104,6 +104,7 @@ void ipc_proxy_add_provider(crm_client_t *client);
0240e4
 void ipc_proxy_remove_provider(crm_client_t *client);
0240e4
 void ipc_proxy_forward_client(crm_client_t *client, xmlNode *xml);
0240e4
 crm_client_t *ipc_proxy_get_provider(void);
0240e4
+int ipc_proxy_shutdown_req(crm_client_t *ipc_proxy);
0240e4
 #endif
0240e4
 
0240e4
 #endif
0240e4
-- 
0240e4
1.8.3.1
0240e4