Blame SOURCES/0004-Build-sbd-pacemaker-Query-CIB-directly-with-the-API.patch

6f8c14
From ef40f6a0fdc178828fbde6f1303e5ee58bfb822a Mon Sep 17 00:00:00 2001
6f8c14
From: "Gao,Yan" <ygao@suse.com>
6f8c14
Date: Wed, 7 Mar 2018 17:50:29 +0100
6f8c14
Subject: [PATCH] Build: sbd-pacemaker: Query CIB directly with the API instead
6f8c14
 of get_cib_copy()
6f8c14
6f8c14
get_cib_copy() has been dropped from pacemaker 2.0 branch as of:
6f8c14
https://github.com/ClusterLabs/pacemaker/commit/32c75b7be
6f8c14
---
6f8c14
 src/sbd-pacemaker.c | 39 +++++++++++++++++++++++++++++++++++----
6f8c14
 1 file changed, 35 insertions(+), 4 deletions(-)
6f8c14
6f8c14
diff --git a/src/sbd-pacemaker.c b/src/sbd-pacemaker.c
6f8c14
index b6a8fb6..2f06109 100644
6f8c14
--- a/src/sbd-pacemaker.c
6f8c14
+++ b/src/sbd-pacemaker.c
6f8c14
@@ -109,6 +109,38 @@ mon_cib_connection_destroy(gpointer user_data)
6f8c14
 	return;
6f8c14
 }
6f8c14
 
6f8c14
+static void
6f8c14
+mon_retrieve_current_cib()
6f8c14
+{
6f8c14
+	xmlNode *xml_cib = NULL;
6f8c14
+	int options = cib_scope_local | cib_sync_call;
6f8c14
+	int rc = pcmk_ok;
6f8c14
+
6f8c14
+	free_xml(current_cib);
6f8c14
+	current_cib = NULL;
6f8c14
+
6f8c14
+	rc = cib->cmds->query(cib, NULL, &xml_cib, options);
6f8c14
+
6f8c14
+	if (rc != pcmk_ok) {
6f8c14
+		crm_err("Couldn't retrieve the CIB: %s (%d)", pcmk_strerror(rc), rc);
6f8c14
+		free_xml(xml_cib);
6f8c14
+		return;
6f8c14
+
6f8c14
+	} else if (xml_cib == NULL) {
6f8c14
+		crm_err("Couldn't retrieve the CIB: empty result");
6f8c14
+		return;
6f8c14
+	}
6f8c14
+
6f8c14
+	if (safe_str_eq(crm_element_name(xml_cib), XML_TAG_CIB)) {
6f8c14
+		current_cib = xml_cib;
6f8c14
+
6f8c14
+	} else {
6f8c14
+		free_xml(xml_cib);
6f8c14
+	}
6f8c14
+
6f8c14
+	return;
6f8c14
+}
6f8c14
+
6f8c14
 static gboolean
6f8c14
 mon_timer_notify(gpointer data)
6f8c14
 {
6f8c14
@@ -121,8 +153,7 @@ mon_timer_notify(gpointer data)
6f8c14
 
6f8c14
 	if (cib_connected) {
6f8c14
 		if (counter == counter_max) {
6f8c14
-			free_xml(current_cib);
6f8c14
-			current_cib = get_cib_copy(cib);
6f8c14
+			mon_retrieve_current_cib();
6f8c14
 			mon_refresh_state(NULL);
6f8c14
 			counter = 0;
6f8c14
 		} else {
6f8c14
@@ -163,7 +194,7 @@ cib_connect(gboolean full)
6f8c14
 			return rc;
6f8c14
 		}
6f8c14
 
6f8c14
-		current_cib = get_cib_copy(cib);
6f8c14
+		mon_retrieve_current_cib();
6f8c14
 		mon_refresh_state(NULL);
6f8c14
 
6f8c14
 		if (full) {
6f8c14
@@ -308,7 +339,7 @@ crm_diff_update(const char *event, xmlNode * msg)
6f8c14
 	}
6f8c14
 
6f8c14
 	if (current_cib == NULL) {
6f8c14
-		current_cib = get_cib_copy(cib);
6f8c14
+		mon_retrieve_current_cib();
6f8c14
 	}
6f8c14
 
6f8c14
     /* Refresh
6f8c14
-- 
6f8c14
1.8.3.1
6f8c14