diff options
author | Eric Wong <e@80x24.org> | 2023-09-25 10:17:13 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-09-25 23:14:44 +0000 |
commit | 8addd1ec64c6e8b4b49e6a4dc8884fd2ee65fe49 (patch) | |
tree | e505527752aa40f3c3483ed56b5575cea5188eaf /lib | |
parent | 9e49a6ebc0dfcb63fd6e9a79ea52be5c0f41b123 (diff) | |
download | public-inbox-8addd1ec64c6e8b4b49e6a4dc8884fd2ee65fe49.tar.gz |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/DS.pm | 9 | ||||
-rw-r--r-- | lib/PublicInbox/LEI.pm | 1 | ||||
-rw-r--r-- | 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"; } |