|
|
79092b |
From 958c0035aa6a69149c1a0fa218863c26e755d9e6 Mon Sep 17 00:00:00 2001
|
|
|
79092b |
From: Ryan McCabe <rmccabe@redhat.com>
|
|
|
79092b |
Date: Fri, 19 Jan 2018 11:04:22 -0500
|
|
|
79092b |
Subject: [PATCH] fence_virtd: Return control to main loop on select
|
|
|
79092b |
interruption
|
|
|
79092b |
|
|
|
79092b |
Return control to the dispatch loop if select is interrupted by a
|
|
|
79092b |
signal. The code that retried the select without breaking out of the
|
|
|
79092b |
dispatch loop caused the daemon to not be able to be killed cleanly.
|
|
|
79092b |
|
|
|
79092b |
Resolves: https://github.com/ClusterLabs/fence-virt/issues/10
|
|
|
79092b |
|
|
|
79092b |
Signed-off-by: Ryan McCabe <rmccabe@redhat.com>
|
|
|
79092b |
---
|
|
|
79092b |
server/mcast.c | 9 +++++++--
|
|
|
79092b |
server/serial.c | 9 ++++++---
|
|
|
79092b |
server/tcp.c | 9 +++++++--
|
|
|
79092b |
4 files changed, 28 insertions(+), 9 deletions(-)
|
|
|
79092b |
|
|
|
79092b |
diff --git a/server/mcast.c b/server/mcast.c
|
|
|
79092b |
index 0336823..e103675 100644
|
|
|
79092b |
--- a/server/mcast.c
|
|
|
79092b |
+++ b/server/mcast.c
|
|
|
79092b |
@@ -350,9 +350,14 @@ mcast_dispatch(listener_context_t c, struct timeval *timeout)
|
|
|
79092b |
FD_ZERO(&rfds);
|
|
|
79092b |
FD_SET(info->mc_sock, &rfds);
|
|
|
79092b |
|
|
|
79092b |
- n = _select_retry((info->mc_sock)+1, &rfds, NULL, NULL, timeout);
|
|
|
79092b |
- if (n <= 0)
|
|
|
79092b |
+ n = select((info->mc_sock)+1, &rfds, NULL, NULL, timeout);
|
|
|
79092b |
+ if (n <= 0) {
|
|
|
79092b |
+ if (errno == EINTR || errno == EAGAIN)
|
|
|
79092b |
+ n = 0;
|
|
|
79092b |
+ else
|
|
|
79092b |
+ dbg_printf(2, "select: %s\n", strerror(errno));
|
|
|
79092b |
return n;
|
|
|
79092b |
+ }
|
|
|
79092b |
|
|
|
79092b |
slen = sizeof(sin);
|
|
|
79092b |
len = recvfrom(info->mc_sock, &data, sizeof(data), 0,
|
|
|
79092b |
diff --git a/server/serial.c b/server/serial.c
|
|
|
79092b |
index 70eb22b..23d143d 100644
|
|
|
79092b |
--- a/server/serial.c
|
|
|
79092b |
+++ b/server/serial.c
|
|
|
79092b |
@@ -272,9 +272,12 @@ serial_dispatch(listener_context_t c, struct timeval *timeout)
|
|
|
79092b |
if (info->wake_fd > max)
|
|
|
79092b |
max = info->wake_fd;
|
|
|
79092b |
|
|
|
79092b |
- n = _select_retry(max+1, &rfds, NULL, NULL, timeout);
|
|
|
79092b |
- if (n < 0) {
|
|
|
79092b |
- dbg_printf(2, "select: %s\n", strerror(errno));
|
|
|
79092b |
+ n = select(max+1, &rfds, NULL, NULL, timeout);
|
|
|
79092b |
+ if (n <= 0) {
|
|
|
79092b |
+ if (errno == EINTR || errno == EAGAIN)
|
|
|
79092b |
+ n = 0;
|
|
|
79092b |
+ else
|
|
|
79092b |
+ dbg_printf(2, "select: %s\n", strerror(errno));
|
|
|
79092b |
return n;
|
|
|
79092b |
}
|
|
|
79092b |
|
|
|
79092b |
diff --git a/server/tcp.c b/server/tcp.c
|
|
|
79092b |
index 09366b7..bbd347e 100644
|
|
|
79092b |
--- a/server/tcp.c
|
|
|
79092b |
+++ b/server/tcp.c
|
|
|
79092b |
@@ -278,9 +278,14 @@ tcp_dispatch(listener_context_t c, struct timeval *timeout)
|
|
|
79092b |
FD_ZERO(&rfds);
|
|
|
79092b |
FD_SET(info->listen_sock, &rfds);
|
|
|
79092b |
|
|
|
79092b |
- n = _select_retry(info->listen_sock + 1, &rfds, NULL, NULL, timeout);
|
|
|
79092b |
- if (n <= 0)
|
|
|
79092b |
+ n = select(info->listen_sock + 1, &rfds, NULL, NULL, timeout);
|
|
|
79092b |
+ if (n <= 0) {
|
|
|
79092b |
+ if (errno == EINTR || errno == EAGAIN)
|
|
|
79092b |
+ n = 0;
|
|
|
79092b |
+ else
|
|
|
79092b |
+ dbg_printf(2, "select: %s\n", strerror(errno));
|
|
|
79092b |
return n;
|
|
|
79092b |
+ }
|
|
|
79092b |
|
|
|
79092b |
client_fd = accept(info->listen_sock, NULL, NULL);
|
|
|
79092b |
if (client_fd < 0) {
|