From patchwork Fri Mar 2 21:18:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10255701 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BA2D36037F for ; Fri, 2 Mar 2018 21:20:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A933228534 for ; Fri, 2 Mar 2018 21:20:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DCAF28511; Fri, 2 Mar 2018 21:20:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7741728535 for ; Fri, 2 Mar 2018 21:20:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B07275D697; Fri, 2 Mar 2018 21:20:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 984E05F73A; Fri, 2 Mar 2018 21:20:04 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E282518033EF; Fri, 2 Mar 2018 21:20:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w22LIV5H026006 for ; Fri, 2 Mar 2018 16:18:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 615B42AE4B; Fri, 2 Mar 2018 21:18:31 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 339B3620A8; Fri, 2 Mar 2018 21:18:29 +0000 (UTC) Received: from smtp.nue.novell.com (smtp.nue.novell.com [195.135.221.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F1D1180F7A; Fri, 2 Mar 2018 21:18:26 +0000 (UTC) Received: from emea4-mta.ukb.novell.com ([10.120.13.87]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Fri, 02 Mar 2018 22:18:25 +0100 Received: from apollon.suse.de.de (nwb-a10-snat.microfocus.com [10.120.13.202]) by emea4-mta.ukb.novell.com with ESMTP (TLS encrypted); Fri, 02 Mar 2018 21:18:19 +0000 From: Martin Wilck To: Benjamin Marzinski , Bart Van Assche Date: Fri, 2 Mar 2018 22:18:07 +0100 Message-Id: <20180302211807.11434-1-mwilck@suse.com> In-Reply-To: <20180302200048.GJ14513@octiron.msp.redhat.com> References: <20180302200048.GJ14513@octiron.msp.redhat.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 02 Mar 2018 21:18:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 02 Mar 2018 21:18:28 +0000 (UTC) for IP:'195.135.221.5' DOMAIN:'smtp.nue.novell.com' HELO:'smtp.nue.novell.com' FROM:'mwilck@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 195.135.221.5 smtp.nue.novell.com 195.135.221.5 smtp.nue.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com Subject: [dm-devel] [PATCH] multipathd: fix inverted signal blocking logic X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 02 Mar 2018 21:20:06 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;