about summary refs log tree commit homepage
path: root/lib/PublicInbox/DS.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-09-08 10:51:13 +0000
committerEric Wong <e@80x24.org>2023-09-08 20:43:16 +0000
commitfd0f545da088c6802e4601c39d39e6b38fbb8fc4 (patch)
treef12d36395250d1ace84d34d4de80b550540dd0a5 /lib/PublicInbox/DS.pm
parent232c35005bd8ff44104267e47bc908550bb9e471 (diff)
downloadpublic-inbox-fd0f545da088c6802e4601c39d39e6b38fbb8fc4.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/DS.pm')
-rw-r--r--lib/PublicInbox/DS.pm16
1 files 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