about summary refs log tree commit homepage
path: root/lib/PublicInbox/Search.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/Search.pm')
-rw-r--r--lib/PublicInbox/Search.pm15
1 files changed, 11 insertions, 4 deletions
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