File bsc#1224183-0001-Refactor-libcib-new-function-cib__signon_attempts.patch of Package pacemaker.34780
From 7ab61e764df38b7ec8349d54e46b66a1447b0b59 Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Tue, 2 Jul 2024 00:12:14 +0200
Subject: [PATCH 1/2] Refactor: libcib: new function cib__signon_attempts()
... for future use
It's similar to how it's done in pcmk__connect_ipc().
---
include/crm/cib/internal.h | 3 +++
lib/cib/cib_utils.c | 27 +++++++++++++++++++++++++++
2 files changed, 30 insertions(+)
Index: pacemaker-2.1.2+20211124.ada5c3b36/include/crm/cib/internal.h
===================================================================
--- pacemaker-2.1.2+20211124.ada5c3b36.orig/include/crm/cib/internal.h
+++ pacemaker-2.1.2+20211124.ada5c3b36/include/crm/cib/internal.h
@@ -230,4 +230,7 @@ cib_callback_client_t* cib__lookup_id (i
*/
int cib__signon_query(cib_t **cib, xmlNode **cib_object);
+int cib__signon_attempts(cib_t *cib, const char *name, enum cib_conn_type type,
+ int attempts);
+
#endif
Index: pacemaker-2.1.2+20211124.ada5c3b36/lib/cib/cib_utils.c
===================================================================
--- pacemaker-2.1.2+20211124.ada5c3b36.orig/lib/cib/cib_utils.c
+++ pacemaker-2.1.2+20211124.ada5c3b36/lib/cib/cib_utils.c
@@ -822,3 +822,29 @@ cib__signon_query(cib_t **cib, xmlNode *
return rc;
}
}
+
+cib__signon_attempts(cib_t *cib, const char *name, enum cib_conn_type type,
+ int attempts)
+{
+ int rc = pcmk_rc_ok;
+
+ crm_trace("Attempting connection to CIB manager (up to %d time%s)",
+ attempts, pcmk__plural_s(attempts));
+
+ for (int remaining = attempts - 1; remaining >= 0; --remaining) {
+ rc = cib->cmds->signon(cib, name, type);
+
+ if ((rc == pcmk_rc_ok)
+ || (remaining == 0)
+ || ((errno != EAGAIN) && (errno != EALREADY))) {
+ break;
+ }
+
+ // Retry after soft error (interrupted by signal, etc.)
+ pcmk__sleep_ms((attempts - remaining) * 500);
+ crm_debug("Re-attempting connection to CIB manager (%d attempt%s remaining)",
+ remaining, pcmk__plural_s(remaining));
+ }
+
+ return rc;
+}