Blame SOURCES/0016-Fix-sbd-pacemaker-check-for-shutdown-attribute-on-ev.patch

75728b
From c8e3de2a7e98550ea9f27a0c59e13013ce02992d Mon Sep 17 00:00:00 2001
75728b
From: Klaus Wenninger <klaus.wenninger@aon.at>
75728b
Date: Fri, 16 Aug 2019 12:07:32 +0200
75728b
Subject: [PATCH] Fix: sbd-pacemaker: check for shutdown attribute on every
75728b
 cib-diff
75728b
75728b
---
75728b
 src/sbd-pacemaker.c | 22 +++++++++++++++++++++-
75728b
 1 file changed, 21 insertions(+), 1 deletion(-)
75728b
75728b
diff --git a/src/sbd-pacemaker.c b/src/sbd-pacemaker.c
75728b
index 2b35ff6..1217acf 100644
75728b
--- a/src/sbd-pacemaker.c
75728b
+++ b/src/sbd-pacemaker.c
75728b
@@ -383,6 +383,24 @@ mon_trigger_refresh(gpointer user_data)
75728b
     return FALSE;
75728b
 }
75728b
 
75728b
+#define XPATH_SHUTDOWN "//" XML_CIB_TAG_STATE "[@uname='%s']/" \
75728b
+    XML_TAG_TRANSIENT_NODEATTRS "/" XML_TAG_ATTR_SETS "/" \
75728b
+    XML_CIB_TAG_NVPAIR "[@name='" XML_CIB_ATTR_SHUTDOWN "']"
75728b
+
75728b
+static gboolean
75728b
+shutdown_attr_in_cib(void)
75728b
+{
75728b
+    xmlNode *match = NULL;
75728b
+    char *xpath_string;
75728b
+
75728b
+    xpath_string = crm_strdup_printf(XPATH_SHUTDOWN, local_uname);
75728b
+    if (xpath_string) {
75728b
+        match = get_xpath_object(xpath_string, current_cib, LOG_TRACE);
75728b
+        free(xpath_string);
75728b
+    }
75728b
+    return (match != NULL);
75728b
+}
75728b
+
75728b
 static void
75728b
 crm_diff_update(const char *event, xmlNode * msg)
75728b
 {
75728b
@@ -426,8 +444,10 @@ crm_diff_update(const char *event, xmlNode * msg)
75728b
      * - immediately if the last update was more than 1s ago
75728b
      * - every 10 updates
75728b
      * - at most 1s after the last update
75728b
+     * - shutdown attribute for our node set for the first time
75728b
      */
75728b
-    if (updates > 10 || (now - last_refresh) > (reconnect_msec / 1000)) {
75728b
+    if ((!pcmk_shutdown && shutdown_attr_in_cib()) ||
75728b
+	    (updates > 10 || (now - last_refresh) > (reconnect_msec / 1000))) {
75728b
         mon_refresh_state(refresh_timer);
75728b
         updates = 0;
75728b
 
75728b
-- 
75728b
1.8.3.1
75728b