lib/PublicInbox/LeiQuery.pm | 18 ++++++++---------- diff --git a/lib/PublicInbox/LeiQuery.pm b/lib/PublicInbox/LeiQuery.pm index d6e801e328aa410582b3235a91ebbb646212d362..941bc2997737a294f88a52d8a3942fdc9bb1da51 100644 --- a/lib/PublicInbox/LeiQuery.pm +++ b/lib/PublicInbox/LeiQuery.pm @@ -23,14 +23,15 @@ # the main "lei q SEARCH_TERMS" method sub lei_q { my ($self, @argv) = @_; - my $opt = $self->{opt}; - - # --local is enabled by default - # src: LeiXSearch || LeiSearch || Inbox - my @srcs; require PublicInbox::LeiXSearch; require PublicInbox::LeiOverview; - PublicInbox::Config->json; + PublicInbox::Config->json; # preload before forking + my $opt = $self->{opt}; + my @srcs; # any number of LeiXSearch || LeiSearch || Inbox + if ($opt->{'local'} //= 1) { # --local is enabled by default + my $sto = $self->_lei_store(1); + push @srcs, $sto->search; + } my $lxs = PublicInbox::LeiXSearch->new; # --external is enabled by default, but allow --no-external @@ -39,7 +40,6 @@ $self->_externals_each(\&_vivify_external, \@srcs); } my $j = $opt->{jobs} // (scalar(@srcs) > 3 ? 3 : scalar(@srcs)); $j = 1 if !$opt->{thread}; - $j++ if $opt->{'local'}; # for sto->search below $self->atfork_prepare_wq($lxs); $lxs->wq_workers_start('lei_xsearch', $j, $self->oldset); $self->{lxs} = $lxs; @@ -50,10 +50,8 @@ $j = 4 if $j <= 4; # TODO configurable $self->atfork_prepare_wq($l2m); $l2m->wq_workers_start('lei2mail', $j, $self->oldset); } - # no forking workers after this - my $sto = $self->_lei_store(1); - unshift(@srcs, $sto->search) if $opt->{'local'}; + my %mset_opt = map { $_ => $opt->{$_} } qw(thread limit offset); $mset_opt{asc} = $opt->{'reverse'} ? 1 : 0; $mset_opt{qstr} = join(' ', map {;