]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
ipc: support awaitpid in WQ workers
authorEric Wong <e@80x24.org>
Wed, 5 Apr 2023 11:26:52 +0000 (11:26 +0000)
committerEric Wong <e@80x24.org>
Wed, 5 Apr 2023 20:12:11 +0000 (20:12 +0000)
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

index 1f0e87ee939abd3ec764078f9179a57118486939..cca3dacbe0abc6b05f84b6267567047cac834976 100644 (file)
@@ -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