diff options
author | Eric Wong <e@80x24.org> | 2019-11-27 01:33:33 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-11-27 10:25:43 +0000 |
commit | d6674af04cb74a4efd513d938bed8bf7ab2838eb (patch) | |
tree | 98e1924639d6ee8be3cd0bb4d614332a0a1cbef4 /lib/PublicInbox/DS.pm | |
parent | 1e44ee6d429b853a7a87ae58e56241c55ab8c306 (diff) | |
download | public-inbox-d6674af04cb74a4efd513d938bed8bf7ab2838eb.tar.gz |
Our attempt at using a self-pipe in signal handlers was ineffective, since pure Perl code execution is deferred and Perl doesn't use an internal self-pipe/eventfd. In retrospect, I actually prefer the simplicity of Perl in this regard... We can use sigprocmask() from Perl, so we can introduce signalfd(2) and EVFILT_SIGNAL support on Linux and *BSD-based systems, respectively. These OS primitives allow us to avoid a race where Perl checks for signals right before epoll_wait() or kevent() puts the process to sleep. The (few) systems nowadays without signalfd(2) or IO::KQueue will now see wakeups every second to avoid missed signals.
Diffstat (limited to 'lib/PublicInbox/DS.pm')
-rw-r--r-- | lib/PublicInbox/DS.pm | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index 7f7cb85d..17c640f4 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -53,6 +53,7 @@ our ( $LoopTimeout, # timeout of event loop in milliseconds $DoneInit, # if we've done the one-time module init yet @Timers, # timers + $in_loop, ); Reset(); @@ -249,7 +250,7 @@ sub reap_pids { sub enqueue_reap ($) { push @$nextq, \&reap_pids }; sub EpollEventLoop { - local $SIG{CHLD} = \&enqueue_reap; + local $in_loop = 1; while (1) { my @events; my $i; @@ -628,8 +629,7 @@ sub shutdn ($) { # must be called with eval, PublicInbox::DS may not be loaded (see t/qspawn.t) sub dwaitpid ($$$) { my ($pid, $cb, $arg) = @_; - my $chld = $SIG{CHLD}; - if (defined($chld) && $chld eq \&enqueue_reap) { + if ($in_loop) { push @$WaitPids, [ $pid, $cb, $arg ]; # We could've just missed our SIGCHLD, cover it, here: |