|
|
fb144c |
From 2c909b78d8226d4d76f53df1091af40ec5fc54a1 Mon Sep 17 00:00:00 2001
|
|
|
fb144c |
From: Ryan McCabe <rmccabe@redhat.com>
|
|
|
fb144c |
Date: Thu, 25 May 2017 13:34:05 -0400
|
|
|
fb144c |
Subject: [PATCH] fence_virtd: Fix select logic in listener plugins
|
|
|
fb144c |
|
|
|
fb144c |
Don't fail causing the daemon to exit when select() fails with errors
|
|
|
fb144c |
that indicate we should retry.
|
|
|
fb144c |
|
|
|
fb144c |
Signed-off-by: Ryan McCabe <rmccabe@redhat.com>
|
|
|
fb144c |
---
|
|
|
fb144c |
common/fdops.c | 8 +++++---
|
|
|
fb144c |
server/mcast.c | 10 ++--------
|
|
|
fb144c |
server/serial.c | 4 +---
|
|
|
fb144c |
server/tcp.c | 2 +-
|
|
|
fb144c |
4 files changed, 9 insertions(+), 15 deletions(-)
|
|
|
fb144c |
|
|
|
fb144c |
diff --git a/common/fdops.c b/common/fdops.c
|
|
|
fb144c |
index bff8bec..3d89ba1 100644
|
|
|
fb144c |
--- a/common/fdops.c
|
|
|
fb144c |
+++ b/common/fdops.c
|
|
|
fb144c |
@@ -41,9 +41,11 @@ _select_retry(int fdmax, fd_set * rfds, fd_set * wfds, fd_set * xfds,
|
|
|
fb144c |
|
|
|
fb144c |
while (1) {
|
|
|
fb144c |
rv = select(fdmax, rfds, wfds, xfds, timeout);
|
|
|
fb144c |
- if ((rv == -1) && (errno == EINTR))
|
|
|
fb144c |
- /* return on EBADF/EINVAL/ENOMEM; continue on EINTR */
|
|
|
fb144c |
- continue;
|
|
|
fb144c |
+ if (rv == -1) {
|
|
|
fb144c |
+ /* return on EBADF/EINVAL/ENOMEM; continue on EINTR/EAGAIN/ENOMEM */
|
|
|
fb144c |
+ if (errno == EINTR || errno == EAGAIN || errno == ENOMEM)
|
|
|
fb144c |
+ continue;
|
|
|
fb144c |
+ }
|
|
|
fb144c |
return rv;
|
|
|
fb144c |
}
|
|
|
fb144c |
}
|
|
|
fb144c |
diff --git a/server/mcast.c b/server/mcast.c
|
|
|
fb144c |
index f6181aa..8f58fa6 100644
|
|
|
fb144c |
--- a/server/mcast.c
|
|
|
fb144c |
+++ b/server/mcast.c
|
|
|
fb144c |
@@ -350,16 +350,10 @@ mcast_dispatch(listener_context_t c, struct timeval *timeout)
|
|
|
fb144c |
FD_ZERO(&rfds);
|
|
|
fb144c |
FD_SET(info->mc_sock, &rfds);
|
|
|
fb144c |
|
|
|
fb144c |
- n = select((info->mc_sock)+1, &rfds, NULL, NULL, timeout);
|
|
|
fb144c |
- if (n < 0)
|
|
|
fb144c |
+ n = _select_retry((info->mc_sock)+1, &rfds, NULL, NULL, timeout);
|
|
|
fb144c |
+ if (n <= 0)
|
|
|
fb144c |
return n;
|
|
|
fb144c |
|
|
|
fb144c |
- /*
|
|
|
fb144c |
- * If no requests, we're done
|
|
|
fb144c |
- */
|
|
|
fb144c |
- if (n == 0)
|
|
|
fb144c |
- return 0;
|
|
|
fb144c |
-
|
|
|
fb144c |
slen = sizeof(sin);
|
|
|
fb144c |
len = recvfrom(info->mc_sock, &data, sizeof(data), 0,
|
|
|
fb144c |
(struct sockaddr *)&sin, &slen);
|
|
|
fb144c |
diff --git a/server/serial.c b/server/serial.c
|
|
|
fb144c |
index 558292a..70eb22b 100644
|
|
|
fb144c |
--- a/server/serial.c
|
|
|
fb144c |
+++ b/server/serial.c
|
|
|
fb144c |
@@ -272,10 +272,8 @@ serial_dispatch(listener_context_t c, struct timeval *timeout)
|
|
|
fb144c |
if (info->wake_fd > max)
|
|
|
fb144c |
max = info->wake_fd;
|
|
|
fb144c |
|
|
|
fb144c |
- n = select(max+1, &rfds, NULL, NULL, timeout);
|
|
|
fb144c |
+ n = _select_retry(max+1, &rfds, NULL, NULL, timeout);
|
|
|
fb144c |
if (n < 0) {
|
|
|
fb144c |
- if (errno == ETIMEDOUT || errno == EINTR || errno == EAGAIN)
|
|
|
fb144c |
- return 0;
|
|
|
fb144c |
dbg_printf(2, "select: %s\n", strerror(errno));
|
|
|
fb144c |
return n;
|
|
|
fb144c |
}
|
|
|
fb144c |
diff --git a/server/tcp.c b/server/tcp.c
|
|
|
fb144c |
index fc9caca..0002e8f 100644
|
|
|
fb144c |
--- a/server/tcp.c
|
|
|
fb144c |
+++ b/server/tcp.c
|
|
|
fb144c |
@@ -276,7 +276,7 @@ tcp_dispatch(listener_context_t c, struct timeval *timeout)
|
|
|
fb144c |
FD_ZERO(&rfds);
|
|
|
fb144c |
FD_SET(info->listen_sock, &rfds);
|
|
|
fb144c |
|
|
|
fb144c |
- n = select(info->listen_sock + 1, &rfds, NULL, NULL, timeout);
|
|
|
fb144c |
+ n = _select_retry(info->listen_sock + 1, &rfds, NULL, NULL, timeout);
|
|
|
fb144c |
if (n <= 0)
|
|
|
fb144c |
return n;
|
|
|
fb144c |
|