From: Eric Wong Date: Tue, 21 May 2019 23:22:05 +0000 (+0000) Subject: Merge remote-tracking branch 'origin/xap-optional' into master X-Git-Tag: v1.2.0~269 X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=e220b8b2ee5cfd458167dc2c6c92726352c4c80e Merge remote-tracking branch 'origin/xap-optional' into master * origin/xap-optional: admin: improve warnings and errors for missing modules searchidx: do not create empty Xapian partitions for basic lazy load Xapian and make it optional for v2 www: use Inbox->over where appropriate nntp: use Inbox->over directly inbox: add ->over method to ease access --- e220b8b2ee5cfd458167dc2c6c92726352c4c80e diff --cc lib/PublicInbox/Inbox.pm index 0b118b28,813ed997..0d86771f --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@@ -23,14 -25,8 +23,14 @@@ sub cleanup_task () my $next = {}; for my $ibx (values %$CLEANUP) { my $again; - foreach my $f (qw(mm search over)) { - delete $ibx->{$f} if SvREFCNT($ibx->{$f}) == 1; + if ($have_devel_peek) { - foreach my $f (qw(mm search)) { ++ foreach my $f (qw(mm search over)) { + # we bump refcnt by assigning tmp, here: + my $tmp = $ibx->{$f} or next; + next if Devel::Peek::SvREFCNT($tmp) > 2; + delete $ibx->{$f}; + # refcnt is zero when tmp is out-of-scope + } } my $expire = time - 60; if (my $git = $ibx->{git}) { @@@ -41,9 -37,7 +41,10 @@@ $again = 1 if $git->cleanup($expire); } } - $again ||= !!($ibx->{over} || $ibx->{mm} || $ibx->{search}); + if ($have_devel_peek) { - $again ||= !!($ibx->{mm} || $ibx->{search}); ++ $again ||= !!($ibx->{over} || $ibx->{mm} || ++ $ibx->{search}); + } $next->{"$ibx"} = $ibx if $again; } $CLEANUP = $next; diff --cc lib/PublicInbox/Search.pm index bb4bd454,b1e62f4c..eae10d8e --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@@ -17,6 -16,17 +16,21 @@@ use PublicInbox::SearchMsg use PublicInbox::MIME; use PublicInbox::MID qw/id_compress/; use PublicInbox::Over; + my $QP_FLAGS; + sub load_xapian () { + $QP_FLAGS ||= eval { + require Search::Xapian; + Search::Xapian->import(qw(:standard)); + + # n.b. FLAG_PURE_NOT is expensive not suitable for a public + # website as it could become a denial-of-service vector ++ # FLAG_PHRASE also seems to cause performance problems ++ # sometimes. ++ # TODO: make this an option, maybe? ++ # or make indexlevel=medium as default + FLAG_PHRASE()|FLAG_BOOLEAN()|FLAG_LOVEHATE()|FLAG_WILDCARD(); + }; + }; # This is English-only, everything else is non-standard and may be confused as # a prefix common in patch emails