File bsc#1224183-0001-Refactor-libcib-new-function-cib__signon_attempts.patch of Package pacemaker.36873
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.0.5+20201202.ba59be712/include/crm/cib/internal.h
===================================================================
--- pacemaker-2.0.5+20201202.ba59be712.orig/include/crm/cib/internal.h
+++ pacemaker-2.0.5+20201202.ba59be712/include/crm/cib/internal.h
@@ -212,4 +212,7 @@ int cib_file_read_and_verify(const char
int cib_file_write_with_digest(xmlNode *cib_root, const char *cib_dirname,
const char *cib_filename);
+int cib__signon_attempts(cib_t *cib, const char *name, enum cib_conn_type type,
+ int attempts);
+
#endif
Index: pacemaker-2.0.5+20201202.ba59be712/lib/cib/cib_utils.c
===================================================================
--- pacemaker-2.0.5+20201202.ba59be712.orig/lib/cib/cib_utils.c
+++ pacemaker-2.0.5+20201202.ba59be712/lib/cib/cib_utils.c
@@ -772,3 +772,29 @@ cib_apply_patch_event(xmlNode *event, xm
}
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.)
+ sleep(attempts - remaining);
+ crm_debug("Re-attempting connection to CIB manager (%d attempt%s remaining)",
+ remaining, pcmk__plural_s(remaining));
+ }
+
+ return rc;
+}