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

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