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

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