File bsc#1224183-0001-ipc-Retry-receiving-credentials-if-the-the-message-i.patch of Package libqb.34760
From 5594d377ac73d37c06bbad1798e87a65f9a12e07 Mon Sep 17 00:00:00 2001
From: Chrissie Caulfield <ccaulfie@redhat.com>
Date: Fri, 25 Nov 2022 07:38:20 +0000
Subject: [PATCH] ipc: Retry receiving credentials if the the message is short
(#476)
ipc: Retry receiving credentials if the the message is short
rhbz#2111711 refers
---
lib/ipc_setup.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
Index: libqb-2.0.4+20211112.a2691b9/lib/ipc_setup.c
===================================================================
--- libqb-2.0.4+20211112.a2691b9.orig/lib/ipc_setup.c
+++ libqb-2.0.4+20211112.a2691b9/lib/ipc_setup.c
@@ -440,6 +440,9 @@ init_ipc_auth_data(int sock, size_t len)
return data;
}
+#define AUTH_RECV_MAX_RETRIES 10
+#define AUTH_RECV_SLEEP_TIME_US 100
+
int32_t
qb_ipcc_us_setup_connect(struct qb_ipcc_connection *c,
struct qb_ipc_connection_response *r)
@@ -447,6 +450,7 @@ qb_ipcc_us_setup_connect(struct qb_ipcc_
int32_t res;
struct qb_ipc_connection_request request;
struct ipc_auth_data *data;
+ int retry_count = 0;
#ifdef QB_LINUX
int off = 0;
int on = 1;
@@ -478,7 +482,14 @@ qb_ipcc_us_setup_connect(struct qb_ipcc_
}
qb_ipc_us_ready(&c->setup, NULL, -1, POLLIN);
+retry:
res = qb_ipc_us_recv_msghdr(data);
+ if (res == -EAGAIN && ++retry_count < AUTH_RECV_MAX_RETRIES) {
+ struct timespec ts = {0, AUTH_RECV_SLEEP_TIME_US*QB_TIME_NS_IN_USEC};
+ struct timespec ts_left = {0, 0};
+ nanosleep(&ts, &ts_left);
+ goto retry;
+ }
#ifdef QB_LINUX
setsockopt(c->setup.u.us.sock, SOL_SOCKET, SO_PASSCRED, &off,