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