From: Eric Wong <e@80x24.org>
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 [thread overview]
Message-ID: <20230121085819.3614832-1-e@80x24.org> (raw)
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;
reply other threads:[~2023-01-21 8:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230121085819.3614832-1-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).