about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiXSearch.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-11-09 10:09:45 +0000
committerEric Wong <e@80x24.org>2023-11-09 21:53:54 +0000
commite15a6fb8ba95295d3e9a5c38054b96f18b038781 (patch)
treeaa3c185c7546277091c151929f1d3ebe5f0d9325 /lib/PublicInbox/LeiXSearch.pm
parente82342c911eeb91a4f50a5392d197c83ef15a07c (diff)
downloadpublic-inbox-e15a6fb8ba95295d3e9a5c38054b96f18b038781.tar.gz
We can rely on Process::IO->DESTROY to close and reap
in these cases.  This is the final step in eliminating
the wantarray invocations of popen_rd (and popen_wr).
Diffstat (limited to 'lib/PublicInbox/LeiXSearch.pm')
-rw-r--r--lib/PublicInbox/LeiXSearch.pm15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index ba8ff293..b09c2462 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -346,14 +346,17 @@ print STDERR $_;
                 my $cmd = $curl->for_uri($lei, $uri);
                 $lei->qerr("# $cmd");
                 $rdr->{2} //= popen_wr(@lbf_tee) if @lbf_tee;
-                my $cfh = popen_rd($cmd, undef, $rdr);
-                my $fh = IO::Uncompress::Gunzip->new($cfh, MultiStream => 1);
-                PublicInbox::MboxReader->mboxrd($fh, \&each_remote_eml, $self,
-                                                $lei, $each_smsg);
+                my $fh = popen_rd($cmd, undef, $rdr);
+                $fh = IO::Uncompress::Gunzip->new($fh,
+                                        MultiStream => 1, AutoClose => 1);
+                eval {
+                        PublicInbox::MboxReader->mboxrd($fh, \&each_remote_eml,
+                                                $self, $lei, $each_smsg);
+                };
+                my ($exc, $code) = ($@, $?);
                 $lei->sto_done_request if delete($self->{-sto_imported});
+                die "E: $exc" if $exc && !$code;
                 my $nr = delete $lei->{-nr_remote_eml} // 0;
-                $cfh->close;
-                my $code = $?;
                 if (!$code) { # don't update if no results, maybe MTA is down
                         $lei->{lss}->cfg_set($key, $start) if $key && $nr;
                         mset_progress($lei, $lei->{-current_url}, $nr, $nr);