From: Eric Wong <e@80x24.org>
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 [thread overview]
Message-ID: <20230908105115.2261125-2-e@80x24.org> (raw)
In-Reply-To: <20230908105115.2261125-1-e@80x24.org>
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<post_loop_do> 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
next prev parent reply other threads:[~2023-09-08 10:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-08 10:51 [PATCH 0/3] sig handling fixes for non-signalfd/kqueue Eric Wong
2023-09-08 10:51 ` Eric Wong [this message]
2023-09-08 10:51 ` [PATCH 2/3] watch: set %SIG " Eric Wong
2023-09-08 10:51 ` [PATCH 3/3] watch: reset HUP + USR1 signal handlers in children Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230908105115.2261125-2-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).