mirror of
https://salsa.debian.org/ha-team/libqb
synced 2025-12-26 14:41:15 +00:00
IPC: split up the recv into chuncks of 2 seconds.
This is because semaphores can't detect the other side has failed/exited. So we rely on the socket poll to tell us. Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
parent
b5c66cab7c
commit
d633b4e2fa
@ -39,6 +39,8 @@
|
||||
#include <semaphore.h>
|
||||
#endif /* HAVE_POSIX_SHARED_SEMAPHORE */
|
||||
|
||||
#define QB_IPC_MAX_WAIT_MS 2000
|
||||
|
||||
/*
|
||||
Client Server
|
||||
SEND CONN REQ ->
|
||||
|
||||
29
lib/ipcc.c
29
lib/ipcc.c
@ -220,6 +220,8 @@ qb_ipcc_sendv_recv(qb_ipcc_connection_t * c,
|
||||
void *res_msg, size_t res_len, int32_t ms_timeout)
|
||||
{
|
||||
ssize_t res = 0;
|
||||
int32_t timeout_now;
|
||||
int32_t timeout_rem = ms_timeout;
|
||||
|
||||
if (c == NULL) {
|
||||
return -EINVAL;
|
||||
@ -243,7 +245,32 @@ qb_ipcc_sendv_recv(qb_ipcc_connection_t * c,
|
||||
return res;
|
||||
}
|
||||
|
||||
return qb_ipcc_recv(c, res_msg, res_len, ms_timeout);
|
||||
do {
|
||||
if (timeout_rem > QB_IPC_MAX_WAIT_MS || ms_timeout == -1) {
|
||||
timeout_now = QB_IPC_MAX_WAIT_MS;
|
||||
} else {
|
||||
timeout_now = timeout_rem;
|
||||
}
|
||||
|
||||
res = qb_ipcc_recv(c, res_msg, res_len, timeout_now);
|
||||
if (res == -ETIMEDOUT) {
|
||||
if (ms_timeout < 0) {
|
||||
res = -EAGAIN;
|
||||
} else {
|
||||
timeout_rem -= timeout_now;
|
||||
if (timeout_rem > 0) {
|
||||
res = -EAGAIN;
|
||||
}
|
||||
}
|
||||
} else if (res < 0 && res != -EAGAIN) {
|
||||
errno = -res;
|
||||
qb_util_perror(LOG_DEBUG,
|
||||
"qb_ipcc_recv %d timeout:(%d/%d)",
|
||||
res, timeout_now, timeout_rem);
|
||||
}
|
||||
} while (res == -EAGAIN && c->is_connected);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int32_t
|
||||
|
||||
Loading…
Reference in New Issue
Block a user