# --local is enabled by default
# src: LeiXSearch || LeiSearch || Inbox
- my @srcs = $opt->{'local'} ? ($sto->search) : ();
+ my @srcs;
require PublicInbox::LeiXSearch;
my $lxs = PublicInbox::LeiXSearch->new;
if ($opt->{external} // 1) {
$self->_externals_each(\&_vivify_external, \@srcs);
}
- my $j = $opt->{jobs} // scalar(@srcs) > 4 ? 4 : scalar(@srcs);
+ my $j = $opt->{jobs} // scalar(@srcs) > 3 ? 3 : scalar(@srcs);
$j = 1 if !$opt->{thread};
- if ($self->{pid}) {
+ $j++ if $opt->{'local'}; # for sto->search below
+ if ($self->{sock}) {
+ $self->atfork_prepare_wq($lxs);
$lxs->wq_workers_start('lei_xsearch', $j, $self->oldset)
// $self->wq_workers($j);
}
+ unshift(@srcs, $sto->search) if $opt->{'local'};
my $out = $opt->{output} // '-';
$out = 'json:/dev/stdout' if $out eq '-';
my $isatty = -t $self->{1};
# my $wcb = PublicInbox::LeiToMail->write_cb($out, $self);
$self->{mset_opt} = \%mset_opt;
$lxs->do_query($self, \@srcs);
- if ($pid_old12) {
+ if ($pid_old12) { # [ pid, stdout, stderr ]
+ my $pid = $pid_old12->[0];
$self->{$_} = $pid_old12->[$_] for (1, 2);
- dwaitpid($pid_old12->[0], undef, $self->{sock});
+ dwaitpid($pid, undef, $self->{sock}) if $pid;
}
}