From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 62C681F454 for ; Wed, 5 Apr 2023 11:26:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1680693962; bh=MS/aMSgjYi2FDmjO+P+AhwIPezkWtJ90PwTjnWEz6Bw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=tddROB0KJEgN9AoQmbkpYvatjkjjYe9TG7+MmC+PMCGHMCsbsThAgL58O7+/uUDZ4 wpO6mkYCUs144HXdxPnGITSO99+ocy02Lp1agf8TMzG4uxJvd0yNmwhdi2OLPK0/Tl NBARcuZqj7Bzo6bhdpXyuvqT6oc2bS9Zr/8Cp4gE= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/7] ipc: support awaitpid in WQ workers Date: Wed, 5 Apr 2023 11:26:52 +0000 Message-Id: <20230405112658.90216-2-e@80x24.org> In-Reply-To: <20230405112658.90216-1-e@80x24.org> References: <20230405112658.90216-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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