From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id EE28D1FA18 for ; Wed, 20 Jan 2021 05:04:50 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/7] lei q: cleanup store initialization Date: Wed, 20 Jan 2021 14:04:46 +0900 Message-Id: <20210120050449.71330-5-e@80x24.org> In-Reply-To: <20210119093435.17955-1-e@80x24.org> References: <20210119093435.17955-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Since we no longer leak an FD for over.sqlite3, we can initialize and actually enable it by default as originally intended. --- lib/PublicInbox/LeiQuery.pm | 18 ++++++++---------- 1 file 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 {;