about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiQuery.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-01-20 14:04:46 +0900
committerEric Wong <e@80x24.org>2021-01-21 03:29:18 +0000
commit7fc6a3487d28b755424c262bf50de9ec2015aa50 (patch)
tree3bcc7875c55369c89853ad8db14914020e03af86 /lib/PublicInbox/LeiQuery.pm
parent31e39c446d8b9534f0b91ffd8e517955aed65d82 (diff)
downloadpublic-inbox-7fc6a3487d28b755424c262bf50de9ec2015aa50.tar.gz
Since we no longer leak an FD for over.sqlite3, we can
initialize and actually enable it by default as originally
intended.
Diffstat (limited to 'lib/PublicInbox/LeiQuery.pm')
-rw-r--r--lib/PublicInbox/LeiQuery.pm18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/PublicInbox/LeiQuery.pm b/lib/PublicInbox/LeiQuery.pm
index d6e801e3..941bc299 100644
--- a/lib/PublicInbox/LeiQuery.pm
+++ b/lib/PublicInbox/LeiQuery.pm
@@ -23,14 +23,15 @@ sub _vivify_external { # _externals_each callback
 # 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 @@ sub lei_q {
         }
         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 @@ sub lei_q {
                 $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 {;