X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=blobdiff_plain;f=lib%2FPublicInbox%2FSearch.pm;h=84c0a22fec077cbafc75b0eaecdae791002ad5b4;hp=91251246ccf4ddf20a94af806787aae89637d14a;hb=87dca6d8d5988c5eb54019cca342450b0b7dd6b7;hpb=3cc5ff405d9054fbf47ac44774fca4f9a72ff65a diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index 91251246..84c0a22f 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -185,10 +185,16 @@ sub get_thread { sub retry_reopen { my ($self, $cb) = @_; - my $ret; for my $i (1..10) { - eval { $ret = $cb->() }; - return $ret unless $@; + if (wantarray) { + my @ret; + eval { @ret = $cb->() }; + return @ret unless $@; + } else { + my $ret; + eval { $ret = $cb->() }; + return $ret unless $@; + } # Exception: The revision being read has been discarded - # you should call Xapian::Database::reopen() if (ref($@) eq 'Search::Xapian::DatabaseModifiedError') { @@ -226,8 +232,9 @@ sub _enquire_once { my @msgs = map { PublicInbox::SearchMsg->load_doc($_->get_document); } $mset->items; + return \@msgs unless wantarray; - { total => $mset->get_matches_estimated, msgs => \@msgs } + ($mset->get_matches_estimated, \@msgs) } # read-write