about summary refs log tree commit homepage
path: root/lib/PublicInbox/IPC.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-04-05 11:26:52 +0000
committerEric Wong <e@80x24.org>2023-04-05 20:12:11 +0000
commitb9905a03c5b76f999301f30ab839cb78293d661d (patch)
treef439495e4d62e47ff8052035bcee709adcb378c4 /lib/PublicInbox/IPC.pm
parent764035c83fe1aff1a0dda778a47b0c9751e74d34 (diff)
downloadpublic-inbox-b9905a03c5b76f999301f30ab839cb78293d661d.tar.gz
Using signalfd is necessary to get reliable signal wakeups w/o
polling on fixed intervals.  This change will make it possible
to use awaitpid in cidx shard workers so they can perform prune
work while waiting on the initial output of `git log -p'.
Diffstat (limited to 'lib/PublicInbox/IPC.pm')
-rw-r--r--lib/PublicInbox/IPC.pm11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/PublicInbox/IPC.pm b/lib/PublicInbox/IPC.pm
index 1f0e87ee..cca3dacb 100644
--- a/lib/PublicInbox/IPC.pm
+++ b/lib/PublicInbox/IPC.pm
@@ -268,12 +268,14 @@ sub sock_defined {
         defined($wqw->{sock});
 }
 
-sub wq_worker_loop ($$) {
-        my ($self, $bcast2) = @_;
+sub wq_worker_loop ($$$) {
+        my ($self, $bcast2, $oldset) = @_;
         my $wqw = PublicInbox::WQWorker->new($self, $self->{-wq_s2});
         PublicInbox::WQWorker->new($self, $bcast2) if $bcast2;
         local @PublicInbox::DS::post_loop_do = (\&sock_defined, $wqw);
-        PublicInbox::DS::event_loop();
+        my $sig = delete($self->{wq_sig});
+        $sig->{CHLD} //= \&PublicInbox::DS::enqueue_reap;
+        PublicInbox::DS::event_loop($sig, $oldset);
         PublicInbox::DS->Reset;
 }
 
@@ -405,8 +407,7 @@ sub _wq_worker_start {
                         local @$self{keys %$fields} = values(%$fields);
                         my $on_destroy = $self->ipc_atfork_child;
                         local @SIG{keys %SIG} = values %SIG;
-                        PublicInbox::DS::sig_setmask($oldset);
-                        wq_worker_loop($self, $bcast2);
+                        wq_worker_loop($self, $bcast2, $oldset);
                 };
                 warn "worker $self->{-wq_ident} PID:$$ died: $@" if $@;
                 undef $end; # trigger exit