From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 6CA161F560 for ; Fri, 8 Sep 2023 10:51:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1694170275; bh=vYBfAkuC4j5wfLCo/DcWIkP0yYAO23WYUaM0Zv2FdCI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Yw0wBxRjHpUPYmd2JkTnWXulOHk74abCpekdgGIVZtKvqXgLxts8m21l8LCeTXNLW aWyza3jCxbuPiMumzz+KUd1kp5o1ucYpo9qlkwqFclAHdCOspymh1qrOGRHU4ROhXs BkeZMIpPoMHXLT5v5mcR3nVNZQlwcljESrH+dYK8= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/3] ds: fix signals unblock for non-signalfd/kqueue Date: Fri, 8 Sep 2023 10:51:13 +0000 Message-ID: <20230908105115.2261125-2-e@80x24.org> In-Reply-To: <20230908105115.2261125-1-e@80x24.org> References: <20230908105115.2261125-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Using the sigset result of allowset() isn't appropriate for SIG_UNBLOCK. We must generate a new signal set off of the $sig dispatch map for use with SIG_UNBLOCK to actually unblock the signals. This is the first part in getting t/imapd.t to pass the reload-after-setting--imap.pollInterval-test when neither signalfd nor kqueue are usable. --- lib/PublicInbox/DS.pm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index 5168a6ee..ff10c9c0 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -259,18 +259,21 @@ sub PostEventLoop () { : 1 } -sub allowset ($) { - my ($sig) = @_; # { signame => whatever } +sub sigset_prep ($$$) { + my ($sig, $init, $each) = @_; # $sig: { signame => whatever } my $ret = POSIX::SigSet->new; - $ret->fillset or die "fillset: $!"; + $ret->$init or die "$init: $!"; for my $s (keys %$sig) { my $num = $SIGNUM{$s} // POSIX->can("SIG$s")->(); - $ret->delset($num) or die "delset ($s => $num): $!"; + $ret->$each($num) or die "$each ($s => $num): $!"; } - for (@UNBLOCKABLE) { $ret->delset($_) or die "delset($_): $!" } + for (@UNBLOCKABLE) { $ret->$each($_) or die "$each ($_): $!" } $ret; } +sub allowset ($) { sigset_prep $_[0], 'fillset', 'delset' } +sub unblockset ($) { sigset_prep $_[0], 'emptyset', 'addset' } + # Start processing IO events. In most daemon programs this never exits. See # C for how to exit the loop. sub event_loop (;$$) { @@ -293,7 +296,8 @@ sub event_loop (;$$) { # wake up every second to accept signals if we don't # have signalfd or IO::KQueue: sig_setmask($oldset) if $oldset; - sigprocmask(SIG_UNBLOCK, allowset($sig)) or die "SIG_UNBLOCK: $!"; + sigprocmask(SIG_UNBLOCK, unblockset($sig)) or + die "SIG_UNBLOCK: $!"; PublicInbox::DS->SetLoopTimeout(1000); } $_[0] = $sigfd = $sig = undef; # $_[0] == sig