lib/PublicInbox/LeiUp.pm | 11 ++++++++--- diff --git a/lib/PublicInbox/LeiUp.pm b/lib/PublicInbox/LeiUp.pm index 3011300dd8369b1f9ff36894e5b5c70cb394c0b3..719736e8597ef7efcd30f8504b68d922773f3f13 100644 --- a/lib/PublicInbox/LeiUp.pm +++ b/lib/PublicInbox/LeiUp.pm @@ -63,6 +63,7 @@ # call lei->dclose when upq is done processing: $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 @@ delete($l->{sock}) or return; # client disconnected if {sock} is gone $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})); }