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 0D7631F47C for ; Sat, 21 Jan 2023 08:58:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1674291499; bh=mk/sc0OI/E+SBTrjdE3gv0TjesGs9hpviqx4AC2uDNA=; h=From:To:Subject:Date:From; b=BpbtNzRtDagNDWaBXHm1ECj0wzV5Fm1b81EbSu3KPu1OWyqCV284aEXAvxFrCBvr4 1qFHCZ8urYsQNRCtWD3JQfAfrsYY/ykAihl8D2Wf6Wjoew8aQbJ6u7s7DE3nTTj+gb 0S1q79whaHNt+ufemovStpe6u/H5+FH7Bj8eFt9A= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] ds: awaitpid: do not clobber entries for reaped processes Date: Sat, 21 Jan 2023 08:58:19 +0000 Message-Id: <20230121085819.3614832-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We must only write to $AWAIT_PIDS on the initial reap attempt. While we're at it, avoid triggering an extra wakeup if we're doing synchronous awaitpid. This seems to eliminate most reliance on Qspawn->DESTROY to call Qspawn->finalize. --- lib/PublicInbox/DS.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index 523d47e4..0a763d0e 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -699,8 +699,8 @@ sub long_response ($$;@) { } sub awaitpid { - my ($pid, @cb_args) = @_; - $AWAIT_PIDS->{$pid} //= @cb_args ? \@cb_args : 0; + my ($pid, @cb_args) = @_; # @cb_args = ($cb, @args), $cb may be undef + $AWAIT_PIDS->{$pid} = \@cb_args if @cb_args; # provide synchronous API if (defined(wantarray) || (!$in_loop && !@cb_args)) { my $ret; @@ -716,9 +716,9 @@ again: delete $AWAIT_PIDS->{$pid}; } return $ret; + } elsif ($in_loop) { # We could've just missed our SIGCHLD, cover it, here: + enqueue_reap(); } - # We could've just missed our SIGCHLD, cover it, here: - enqueue_reap() if $in_loop; } 1;