File bsc#1239629-0007-Refactor-pacemaker-attrd-ability-to-send-a-protocol-.patch of Package pacemaker.38493

From 65df1344fa45a4565c0c38edd5bfc24426070e41 Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Fri, 21 Mar 2025 14:18:15 +0100
Subject: [PATCH 7/8] Refactor: pacemaker-attrd: ability to send a protocol
 message to a single peer

Rename attrd_broadcast_protocol() to attrd_send_protocol().
---
 daemons/attrd/attrd_messages.c  | 24 +++++++++++++++++++-----
 daemons/attrd/pacemaker-attrd.c |  2 +-
 daemons/attrd/pacemaker-attrd.h |  2 +-
 3 files changed, 21 insertions(+), 7 deletions(-)

Index: pacemaker-2.1.5+20221208.a3f44794f/daemons/attrd/attrd_messages.c
===================================================================
--- pacemaker-2.1.5+20221208.a3f44794f.orig/daemons/attrd/attrd_messages.c
+++ pacemaker-2.1.5+20221208.a3f44794f/daemons/attrd/attrd_messages.c
@@ -9,6 +9,7 @@
 
 #include <crm_internal.h>
 
+#include <inttypes.h>   // PRIu32
 #include <glib.h>
 
 #include <crm/common/messages_internal.h>
@@ -223,10 +224,10 @@ attrd_handle_request(pcmk__request_t *re
 
 /*!
     \internal
-    \brief Broadcast private attribute for local node with protocol version
+    \brief Send or broadcast private attribute for local node with protocol version
 */
 void
-attrd_broadcast_protocol(void)
+attrd_send_protocol(const crm_node_t *peer)
 {
     xmlNode *attrd_op = create_xml_node(NULL, __func__);
 
@@ -238,10 +239,24 @@ attrd_broadcast_protocol(void)
     crm_xml_add_int(attrd_op, PCMK__XA_ATTR_IS_PRIVATE, 1);
     pcmk__xe_add_node(attrd_op, attrd_cluster->uname, attrd_cluster->nodeid);
 
-    crm_debug("Broadcasting attrd protocol version %s for node %s",
-              ATTRD_PROTOCOL_VERSION, attrd_cluster->uname);
+    if (peer == NULL) {
+        crm_debug("Broadcasting attrd protocol version %s for node %s[%" PRIu32
+                  "]",
+                  ATTRD_PROTOCOL_VERSION,
+                  pcmk__s(attrd_cluster->uname, "unknown"),
+                  attrd_cluster->nodeid);
+
+    } else {
+        crm_debug("Sending attrd protocol version %s for node %s[%" PRIu32
+                  "] to node %s[%" PRIu32 "]",
+                  ATTRD_PROTOCOL_VERSION,
+                  pcmk__s(attrd_cluster->uname, "unknown"),
+                  attrd_cluster->nodeid,
+                  pcmk__s(peer->uname, "unknown"),
+                  peer->id);
+    }
 
-    attrd_send_message(NULL, attrd_op); /* ends up at attrd_peer_message() */
+    attrd_send_message(peer, attrd_op); /* ends up at attrd_peer_message() */
 
     free_xml(attrd_op);
 }
Index: pacemaker-2.1.5+20221208.a3f44794f/daemons/attrd/pacemaker-attrd.c
===================================================================
--- pacemaker-2.1.5+20221208.a3f44794f.orig/daemons/attrd/pacemaker-attrd.c
+++ pacemaker-2.1.5+20221208.a3f44794f/daemons/attrd/pacemaker-attrd.c
@@ -286,7 +286,7 @@ main(int argc, char **argv)
      * across all nodes. It also ensures that the writer learns our node name,
      * so it can send our attributes to the CIB.
      */
-    attrd_broadcast_protocol();
+    attrd_send_protocol(NULL);
 
     attrd_init_ipc();
     crm_notice("Pacemaker node attribute manager successfully started and accepting connections");
Index: pacemaker-2.1.5+20221208.a3f44794f/daemons/attrd/pacemaker-attrd.h
===================================================================
--- pacemaker-2.1.5+20221208.a3f44794f.orig/daemons/attrd/pacemaker-attrd.h
+++ pacemaker-2.1.5+20221208.a3f44794f/daemons/attrd/pacemaker-attrd.h
@@ -155,7 +155,7 @@ void attrd_peer_clear_failure(pcmk__requ
 void attrd_peer_sync_response(const crm_node_t *peer, bool peer_won,
                               xmlNode *xml);
 
-void attrd_broadcast_protocol(void);
+void attrd_send_protocol(const crm_node_t *peer);
 xmlNode *attrd_client_peer_remove(pcmk__request_t *request);
 xmlNode *attrd_client_clear_failure(pcmk__request_t *request);
 xmlNode *attrd_client_update(pcmk__request_t *request);
openSUSE Build Service is sponsored by