* [PATCH 1/2] ds: force event_loop wakeup on final child death
2023-09-25 10:17 6% [PATCH 0/2] daemon shutdown improvements Eric Wong
@ 2023-09-25 10:17 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2023-09-25 10:17 UTC (permalink / raw)
To: meta
Reaping children needs to keep the event_loop spinning another
round when the @post_loop_do callback may be used to check
on process exit during shutdown.
This allows us to get rid of the hacky SetLoopTimeout calls in
lei-daemon and XapHelper.pm during process shutdown if we're
trying to wait for all PIDs to exit before leaving the event
loop.
---
lib/PublicInbox/DS.pm | 9 ++++++---
lib/PublicInbox/LEI.pm | 1 -
lib/PublicInbox/XapHelper.pm | 1 -
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index 919a4b67..49550b2b 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -216,12 +216,15 @@ sub await_cb ($;@) {
sub reap_pids {
$reap_armed = undef;
while (1) {
- my $pid = waitpid(-1, WNOHANG) // last;
- last if $pid <= 0;
+ my $pid = waitpid(-1, WNOHANG) or return;
if (defined(my $cb_args = delete $AWAIT_PIDS->{$pid})) {
await_cb($pid, @$cb_args) if $cb_args;
- } else {
+ } elsif ($pid == -1 && $! == ECHILD) {
+ return requeue(\&dflush); # force @post_loop_do to run
+ } elsif ($pid > 0) {
warn "W: reaped unknown PID=$pid: \$?=$?\n";
+ } else { # does this happen?
+ return warn("W: waitpid(-1, WNOHANG) => $pid ($!)");
}
}
}
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index be77fa90..432ae61e 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -1316,7 +1316,6 @@ sub lazy_start {
# closing eof_p triggers \&noop wakeup
$listener = $eof_p = $pil = $path = undef;
$lis->close; # DS::close
- PublicInbox::DS->SetLoopTimeout(1000);
};
};
my $sig = {
diff --git a/lib/PublicInbox/XapHelper.pm b/lib/PublicInbox/XapHelper.pm
index e8eeb2dc..8c2b86d6 100644
--- a/lib/PublicInbox/XapHelper.pm
+++ b/lib/PublicInbox/XapHelper.pm
@@ -209,7 +209,6 @@ sub reap_worker { # awaitpid CB
delete $WORKERS{$nr};
if (($? >> 8) == 66) { # EX_NOINPUT
$alive = undef;
- PublicInbox::DS->SetLoopTimeout(1);
} elsif ($?) {
warn "worker[$nr] died \$?=$?\n";
}
^ permalink raw reply related [relevance 7%]
* [PATCH 0/2] daemon shutdown improvements
@ 2023-09-25 10:17 6% Eric Wong
2023-09-25 10:17 7% ` [PATCH 1/2] ds: force event_loop wakeup on final child death Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2023-09-25 10:17 UTC (permalink / raw)
To: meta
More stuff extracted from another branch...
Eric Wong (2):
ds: force event_loop wakeup on final child death
tests: add quit_waiter_pipe and wait_for_eof
lib/PublicInbox/DS.pm | 9 ++++++---
lib/PublicInbox/LEI.pm | 1 -
lib/PublicInbox/TestCommon.pm | 36 +++++++++++++++++++++++++----------
lib/PublicInbox/XapHelper.pm | 1 -
t/httpd-unix.t | 35 ++++++++++------------------------
5 files changed, 42 insertions(+), 40 deletions(-)
^ permalink raw reply [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2023-09-25 10:17 6% [PATCH 0/2] daemon shutdown improvements Eric Wong
2023-09-25 10:17 7% ` [PATCH 1/2] ds: force event_loop wakeup on final child death Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
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).