|
|
97a029 |
commit 5594d377ac73d37c06bbad1798e87a65f9a12e07
|
|
|
97a029 |
Author: Chrissie Caulfield <ccaulfie@redhat.com>
|
|
|
97a029 |
Date: Fri Nov 25 07:38:20 2022 +0000
|
|
|
97a029 |
|
|
|
97a029 |
ipc: Retry receiving credentials if the the message is short (#476)
|
|
|
97a029 |
|
|
|
97a029 |
ipc: Retry receiving credentials if the the message is short
|
|
|
97a029 |
|
|
|
97a029 |
rhbz#2111711 refers
|
|
|
97a029 |
|
|
|
97a029 |
diff --git a/lib/ipc_setup.c b/lib/ipc_setup.c
|
|
|
97a029 |
index 0ef9bb6..0de7115 100644
|
|
|
97a029 |
--- a/lib/ipc_setup.c
|
|
|
97a029 |
+++ b/lib/ipc_setup.c
|
|
|
97a029 |
@@ -473,11 +473,15 @@ qb_ipcc_us_setup_connect(struct qb_ipcc_connection *c,
|
|
|
97a029 |
return 0;
|
|
|
97a029 |
}
|
|
|
97a029 |
|
|
|
97a029 |
+#define AUTH_RECV_MAX_RETRIES 10
|
|
|
97a029 |
+#define AUTH_RECV_SLEEP_TIME_US 100
|
|
|
97a029 |
+
|
|
|
97a029 |
/* Called from ipcc_connect_continue() when async connect socket is active */
|
|
|
97a029 |
int qb_ipcc_setup_connect_continue(struct qb_ipcc_connection *c, struct qb_ipc_connection_response *r)
|
|
|
97a029 |
{
|
|
|
97a029 |
struct ipc_auth_data *data;
|
|
|
97a029 |
int32_t res;
|
|
|
97a029 |
+ int retry_count = 0;
|
|
|
97a029 |
#ifdef QB_LINUX
|
|
|
97a029 |
int off = 0;
|
|
|
97a029 |
#endif
|
|
|
97a029 |
@@ -486,8 +490,14 @@ int qb_ipcc_setup_connect_continue(struct qb_ipcc_connection *c, struct qb_ipc_c
|
|
|
97a029 |
qb_ipcc_us_sock_close(c->setup.u.us.sock);
|
|
|
97a029 |
return -ENOMEM;
|
|
|
97a029 |
}
|
|
|
97a029 |
-
|
|
|
97a029 |
+retry:
|
|
|
97a029 |
res = qb_ipc_us_recv_msghdr(data);
|
|
|
97a029 |
+ if (res == -EAGAIN && ++retry_count < AUTH_RECV_MAX_RETRIES) {
|
|
|
97a029 |
+ struct timespec ts = {0, AUTH_RECV_SLEEP_TIME_US*QB_TIME_NS_IN_USEC};
|
|
|
97a029 |
+ struct timespec ts_left = {0, 0};
|
|
|
97a029 |
+ nanosleep(&ts, &ts_left);
|
|
|
97a029 |
+ goto retry;
|
|
|
97a029 |
+ }
|
|
|
97a029 |
|
|
|
97a029 |
#ifdef QB_LINUX
|
|
|
97a029 |
setsockopt(c->setup.u.us.sock, SOL_SOCKET, SO_PASSCRED, &off,
|