$end;
}
+sub incr {
+ my ($self, $field, $nr) = @_;
+ $self->{counters}->{$field} += $nr;
+}
+
sub workers_start {
my ($lei, $wq, $jobs, $ops, $flds) = @_;
$ops = {
'|' => [ \&sigpipe_handler, $lei ],
'x_it' => [ \&x_it, $lei ],
'child_error' => [ \&child_error, $lei ],
+ 'incr' => [ \&incr, $lei ],
($ops ? %$ops : ()),
};
$ops->{''} //= [ $wq->can('_lei_wq_eof') || \&wq_eof, $lei ];
$wq->wq_workers_start($ident, $jobs, $lei->oldset, $flds);
delete $lei->{pkt_op_p};
my $op_c = delete $lei->{pkt_op_c};
- # {-lei_sock} persists script/lei process until ops->{''} EOF callback
- $op_c->{-lei_sock} = $lei->{sock};
@$end = ();
$lei->event_step_init;
($op_c, $ops);
sub event_step_init {
my ($self) = @_;
- return if $self->{-event_init_done}++;
- if (my $sock = $self->{sock}) { # using DS->EventLoop
+ my $sock = $self->{sock} or return;
+ $self->{-event_init_done} //= do { # persist til $ops done
$self->SUPER::new($sock, EPOLLIN|EPOLLET);
- }
+ $sock;
+ };
}
sub noop {}
# can immediately reread it
sub DESTROY {
my ($self) = @_;
+ if (my $counters = delete $self->{counters}) {
+ for my $k (sort keys %$counters) {
+ my $nr = $counters->{$k};
+ $self->child_error(1 << 8, "$nr $k messages");
+ }
+ }
$self->{1}->autoflush(1) if $self->{1};
stop_pager($self);
# preserve $? for ->fail or ->x_it code
$self->{lei}->{sto}->ipc_do('update_xvmd', $xoids, $eml,
$self->{vmd_mod});
} else {
- ++$self->{missing};
+ ++$self->{unimported};
}
}
my ($lei, @argv) = @_;
my $sto = $lei->_lei_store(1);
$sto->write_prepare($lei);
- my $self = bless { missing => 0 }, __PACKAGE__;
+ my $self = bless {}, __PACKAGE__;
$lei->ale; # refresh and prepare
my $vmd_mod = $self->vmd_mod_extract(\@argv);
return $lei->fail(join("\n", @{$vmd_mod->{err}})) if $vmd_mod->{err};
$lei->wait_wq_events($op_c, $ops);
}
-sub note_missing {
+sub note_unimported {
my ($self) = @_;
- my $n = $self->{missing} or return;
- $self->{lei}->child_error(1 << 8, "$n missed messages");
+ my $n = $self->{unimported} or return;
+ $self->{lei}->{pkt_op_p}->pkt_do('incr', 'unimported', $n);
}
sub ipc_atfork_child {
PublicInbox::LeiInput::input_only_atfork_child($self);
$self->{lse} = $self->{lei}->{sto}->search;
# this goes out-of-scope at worker process exit:
- PublicInbox::OnDestroy->new($$, \¬e_missing, $self);
+ PublicInbox::OnDestroy->new($$, \¬e_unimported, $self);
}
# Workaround bash word-splitting s to ['kw', ':', 'keyword' ...]