[dm-devel] [PATCH] multipathd: fix inverted signal blocking logic

Martin Wilck mwilck at suse.com
Fri Mar 2 21:18:07 UTC 2018


On Fri, 2018-03-02 at 14:00 -0600, Benjamin Marzinski wrote:

> But
> in any case, after commit 534ec4c, we are only blocking SIGUSR2 on
> all
> threads, which is the only signal we don't need to block.  This means

I can see what you mean. Better like this, maybe?

multipathd is supposed to block all signals in all threads, except
the uxlsnr thread which handles termination and reconfiguration
signals (SIGUSR1) in its ppoll() call, SIGUSR2 in the waiter thread, and
occasional SIGALRM. The current logic does exactly the opposite, it blocks
termination signals in SIGPOLL and allows multipathd to be killed e.g.
by SIGALRM.

Fix that bin inverting the logic. The argument to pthread_sigmask and
ppoll is the set of *blocked* signals, not vice versa.

Fixes: 534ec4c "multipathd: Ensure that SIGINT, SIGTERM, SIGHUP and SIGUSR1
are delivered to the uxsock thread"

Signed-off-by: Martin Wilck <mwilck at suse.com>
---
 multipathd/main.c   |  7 +++++--
 multipathd/uxlsnr.c | 10 +++++-----
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/multipathd/main.c b/multipathd/main.c
index 61739ac6ea59..85ee9b713d75 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -2270,10 +2270,13 @@ signal_init(void)
 {
 	sigset_t set;
 
-	sigemptyset(&set);
-	sigaddset(&set, SIGUSR2);
+	/* block all signals */
+	sigfillset(&set);
+	/* SIGPIPE occurs if logging fails */
+	sigdelset(&set, SIGPIPE);
 	pthread_sigmask(SIG_SETMASK, &set, NULL);
 
+	/* Other signals will be unblocked in the uxlsnr thread */
 	signal_set(SIGHUP, sighup);
 	signal_set(SIGUSR1, sigusr1);
 	signal_set(SIGUSR2, sigusr2);
diff --git a/multipathd/uxlsnr.c b/multipathd/uxlsnr.c
index 98ac25a68c43..a2ca36ba1653 100644
--- a/multipathd/uxlsnr.c
+++ b/multipathd/uxlsnr.c
@@ -170,11 +170,11 @@ void * uxsock_listen(uxsock_trigger_fn uxsock_trigger, void * trigger_data)
 		condlog(0, "uxsock: failed to allocate poll fds");
 		return NULL;
 	}
-	sigemptyset(&mask);
-	sigaddset(&mask, SIGINT);
-	sigaddset(&mask, SIGTERM);
-	sigaddset(&mask, SIGHUP);
-	sigaddset(&mask, SIGUSR1);
+	sigfillset(&mask);
+	sigdelset(&mask, SIGINT);
+	sigdelset(&mask, SIGTERM);
+	sigdelset(&mask, SIGHUP);
+	sigdelset(&mask, SIGUSR1);
 	while (1) {
 		struct client *c, *tmp;
 		int i, poll_count, num_clients;
-- 
2.16.1




More information about the dm-devel mailing list