about summary refs log tree commit homepage
path: root/lib/PublicInbox/Inbox.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-08-24 22:49:24 +0000
committerEric Wong <e@80x24.org>2021-08-25 08:00:08 +0000
commit796e7215a167f36d0b950631c3b1e44fa47fec07 (patch)
tree163bd59dc121be1b032e18db69421f9600cede35 /lib/PublicInbox/Inbox.pm
parent5a27f82749d723625848c8d1cf216a0f4de73597 (diff)
downloadpublic-inbox-796e7215a167f36d0b950631c3b1e44fa47fec07.tar.gz
imap+nntp: die loudly if ->mm or ->over disappear
While the WWW front-end can gracefully handle ->mm and ->over
disappearing (in most cases), IMAP+NNTP front-ends are completely
dependent on these and failed mysteriously when they go missing
after startup.

These will hopefully make issues like what Konstantin
encountered more obvious:

Link: https://public-inbox.org/meta/20210824204855.ejspej4z7r2rpu63@nitro.local/
Diffstat (limited to 'lib/PublicInbox/Inbox.pm')
-rw-r--r--lib/PublicInbox/Inbox.pm19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index b94ffdb0..df140cac 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -8,6 +8,7 @@ use PublicInbox::Git;
 use PublicInbox::MID qw(mid2path);
 use PublicInbox::Eml;
 use List::Util qw(max);
+use Carp qw(croak);
 
 # Long-running "git-cat-file --batch" processes won't notice
 # unlinked packs, so we need to restart those processes occasionally.
@@ -168,8 +169,8 @@ sub max_git_epoch {
 }
 
 sub mm {
-        my ($self) = @_;
-        $self->{mm} ||= eval {
+        my ($self, $req) = @_;
+        $self->{mm} //= eval {
                 require PublicInbox::Msgmap;
                 my $dir = $self->{inboxdir};
                 if ($self->version >= 2) {
@@ -177,7 +178,7 @@ sub mm {
                 } else {
                         PublicInbox::Msgmap->new($dir);
                 }
-        };
+        } // ($req ? croak("E: $@") : undef);
 }
 
 sub search {
@@ -195,19 +196,19 @@ sub search {
 sub isrch { $_[0]->{isrch} // search($_[0]) }
 
 sub over {
-        $_[0]->{over} //= eval {
-                my $srch = $_[0]->{search} //= do {
-                        _cleanup_later($_[0]);
+        my ($self, $req) = @_;
+        $self->{over} //= eval {
+                my $srch = $self->{search} //= do {
+                        _cleanup_later($self);
                         require PublicInbox::Search;
-                        PublicInbox::Search->new($_[0]);
+                        PublicInbox::Search->new($self);
                 };
                 my $over = PublicInbox::Over->new("$srch->{xpfx}/over.sqlite3");
                 $over->dbh; # may fail
                 $over;
-        };
+        } // ($req ? croak("E: $@") : undef);
 }
 
-
 sub try_cat {
         my ($path) = @_;
         open(my $fh, '<', $path) or return '';