]> Sergey Matveev's repositories - public-inbox.git/commitdiff
miscsearch: take reopen from Search and use it
authorEric Wong <e@80x24.org>
Sun, 27 Dec 2020 11:01:42 +0000 (11:01 +0000)
committerEric Wong <e@80x24.org>
Mon, 28 Dec 2020 23:18:49 +0000 (23:18 +0000)
As with ExtSearch, MiscSearch lacks a janky cleanup timer of
PublicInbox::Inbox objects, leading to info about
inboxes/newsgroups going stale.  Fortunately, we don't use
MiscSearch very heavily, yet.

In the future, we may be able to detect new inboxes without
having to SIGHUP or restart daemons using MiscSearch.

lib/PublicInbox/MiscSearch.pm
lib/PublicInbox/WwwListing.pm

index c6ce255fc90ffebe94aba7d2de4619d28ad7ae3c..6683d5644379129fdb976fa56c187a247c99c2f8 100644 (file)
@@ -73,6 +73,7 @@ sub misc_enquire_once { # retry_reopen callback
 sub mset {
        my ($self, $qs, $opt) = @_;
        $opt ||= {};
+       reopen($self);
        my $qp = $self->{qp} //= mi_qp_new($self);
        $qs = 'type:inbox' if $qs eq '';
        my $qr = $qp->parse_query($qs, $PublicInbox::Search::QP_FLAGS);
@@ -184,4 +185,7 @@ sub nntpd_cache_load {
        retry_reopen($self, \&_nntpd_cache_load);
 }
 
+no warnings 'once';
+*reopen = \&PublicInbox::Search::reopen;
+
 1;
index fce0e530b24feb91393951cf24223c99ffb4c115..4b3f1674ed18150c820b2b45101c1868ab8c6ce8 100644 (file)
@@ -69,6 +69,9 @@ sub hide_key { 'www' }
 sub response {
        my ($class, $ctx) = @_;
        bless $ctx, $class;
+       if (my $ALL = $ctx->{www}->{pi_cfg}->ALL) {
+               $ALL->misc->reopen;
+       }
        my $re = $ctx->url_regexp or return $ctx->psgi_triple;
        my $iter = PublicInbox::ConfigIter->new($ctx->{www}->{pi_cfg},
                                                \&list_match_i, $re, $ctx);