Blob Blame History Raw
From ef40f6a0fdc178828fbde6f1303e5ee58bfb822a Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Wed, 7 Mar 2018 17:50:29 +0100
Subject: [PATCH] Build: sbd-pacemaker: Query CIB directly with the API instead
 of get_cib_copy()

get_cib_copy() has been dropped from pacemaker 2.0 branch as of:
https://github.com/ClusterLabs/pacemaker/commit/32c75b7be
---
 src/sbd-pacemaker.c | 39 +++++++++++++++++++++++++++++++++++----
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/src/sbd-pacemaker.c b/src/sbd-pacemaker.c
index b6a8fb6..2f06109 100644
--- a/src/sbd-pacemaker.c
+++ b/src/sbd-pacemaker.c
@@ -109,6 +109,38 @@ mon_cib_connection_destroy(gpointer user_data)
 	return;
 }
 
+static void
+mon_retrieve_current_cib()
+{
+	xmlNode *xml_cib = NULL;
+	int options = cib_scope_local | cib_sync_call;
+	int rc = pcmk_ok;
+
+	free_xml(current_cib);
+	current_cib = NULL;
+
+	rc = cib->cmds->query(cib, NULL, &xml_cib, options);
+
+	if (rc != pcmk_ok) {
+		crm_err("Couldn't retrieve the CIB: %s (%d)", pcmk_strerror(rc), rc);
+		free_xml(xml_cib);
+		return;
+
+	} else if (xml_cib == NULL) {
+		crm_err("Couldn't retrieve the CIB: empty result");
+		return;
+	}
+
+	if (safe_str_eq(crm_element_name(xml_cib), XML_TAG_CIB)) {
+		current_cib = xml_cib;
+
+	} else {
+		free_xml(xml_cib);
+	}
+
+	return;
+}
+
 static gboolean
 mon_timer_notify(gpointer data)
 {
@@ -121,8 +153,7 @@ mon_timer_notify(gpointer data)
 
 	if (cib_connected) {
 		if (counter == counter_max) {
-			free_xml(current_cib);
-			current_cib = get_cib_copy(cib);
+			mon_retrieve_current_cib();
 			mon_refresh_state(NULL);
 			counter = 0;
 		} else {
@@ -163,7 +194,7 @@ cib_connect(gboolean full)
 			return rc;
 		}
 
-		current_cib = get_cib_copy(cib);
+		mon_retrieve_current_cib();
 		mon_refresh_state(NULL);
 
 		if (full) {
@@ -308,7 +339,7 @@ crm_diff_update(const char *event, xmlNode * msg)
 	}
 
 	if (current_cib == NULL) {
-		current_cib = get_cib_copy(cib);
+		mon_retrieve_current_cib();
 	}
 
     /* Refresh
-- 
1.8.3.1