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'.
---
lib/PublicInbox/IPC.pm | 11 ++++++-----
1 file 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