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