about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-10-14 13:16:08 +0000
committerEric Wong <e@80x24.org>2021-10-15 02:23:27 +0000
commite482a9fb713db1c14b52d6db05049842605764e2 (patch)
tree168793e7d0c390e90e08b798004e4e89db1ebaf6
parent4b5a1b5787edee2a3b6cc10a3ccc5721f1414268 (diff)
downloadpublic-inbox-e482a9fb713db1c14b52d6db05049842605764e2.tar.gz
We need to use DESTROY here to ensure we wait for workers, too;
not just the initial dispatch.

Fixes: cafbd77b3c82167d ("lei up: avoid excessively parallel --all")
-rw-r--r--lib/PublicInbox/LeiUp.pm11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/PublicInbox/LeiUp.pm b/lib/PublicInbox/LeiUp.pm
index 3011300d..719736e8 100644
--- a/lib/PublicInbox/LeiUp.pm
+++ b/lib/PublicInbox/LeiUp.pm
@@ -63,6 +63,7 @@ sub redispatch_all ($$) {
         $op_c->{ops} = { '' => [ $lei->can('dclose'), $lei ] };
         my @first_batch = splice(@$upq, 0, $j); # initial parallelism
         $lei->{-upq} = $upq;
+        $lei->{daemon_pid} = $$;
         $lei->event_step_init; # wait for client disconnects
         for my $out (@first_batch) {
                 PublicInbox::DS::requeue(
@@ -158,18 +159,22 @@ sub event_step { # runs via PublicInbox::DS::requeue
         $l->{opt} = { %{$l->{opt}} }; # deep copy
         delete $l->{opt}->{all};
         $l->qerr("# updating $self->{out}");
-        $l->{up_op_p} = $self->{op_p}; # ($l => $lei => script/lei)
+        my $o = " (output: $self->{out})"; # add to all warnings
         my $cb = $SIG{__WARN__} // \&CORE::warn;
-        my $o = " (output: $self->{out})";
         local $SIG{__WARN__} = sub {
                 my @m = @_;
                 push(@m, $o) if !@m || $m[-1] !~ s/\n\z/$o\n/;
                 $cb->(@m);
         };
+        $l->{-up1} = $self;
         eval { $l->dispatch('up', $self->{out}) };
         $lei->child_error(0, $@) if $@ || $l->{failed}; # lei->fail()
+}
 
-        # onto the next:
+sub DESTROY {
+        my ($self) = @_;
+        my $lei = $self->{lei}; # the original, from lei_up
+        return if $lei->{daemon_pid} != $$;
         my $out = shift(@{$lei->{-upq}}) or return;
         PublicInbox::DS::requeue(nxt($lei, $out, $self->{op_p}));
 }