about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiRemote.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/LeiRemote.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/LeiRemote.pm')
-rw-r--r--lib/PublicInbox/LeiRemote.pm14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/PublicInbox/LeiRemote.pm b/lib/PublicInbox/LeiRemote.pm
index 54750062..559fb8d5 100644
--- a/lib/PublicInbox/LeiRemote.pm
+++ b/lib/PublicInbox/LeiRemote.pm
@@ -12,7 +12,6 @@ use IO::Uncompress::Gunzip;
 use PublicInbox::MboxReader;
 use PublicInbox::Spawn qw(popen_rd);
 use PublicInbox::LeiCurl;
-use PublicInbox::AutoReap;
 use PublicInbox::ContentHash qw(git_sha);
 
 sub new {
@@ -22,7 +21,7 @@ sub new {
 
 sub isrch { $_[0] } # SolverGit expcets this
 
-sub _each_mboxrd_eml { # callback for MboxReader->mboxrd
+sub each_mboxrd_eml { # callback for MboxReader->mboxrd
         my ($eml, $self) = @_;
         my $lei = $self->{lei};
         my $xoids = $lei->{ale}->xoids_for($eml, 1);
@@ -47,14 +46,13 @@ sub mset {
         $uri->query_form(q => $qstr, x => 'm', r => 1); # r=1: relevance
         my $cmd = $curl->for_uri($self->{lei}, $uri);
         $self->{lei}->qerr("# $cmd");
-        my ($fh, $pid) = popen_rd($cmd, undef, { 2 => $lei->{2} });
-        my $ar = PublicInbox::AutoReap->new($pid);
         $self->{smsg} = [];
-        $fh = IO::Uncompress::Gunzip->new($fh, MultiStream => 1);
-        PublicInbox::MboxReader->mboxrd($fh, \&_each_mboxrd_eml, $self);
+        my $fh = popen_rd($cmd, undef, { 2 => $lei->{2} });
+        $fh = IO::Uncompress::Gunzip->new($fh, MultiStream=>1, AutoClose=>1);
+        eval { PublicInbox::MboxReader->mboxrd($fh, \&each_mboxrd_eml, $self) };
+        my $err = $@ ? ": $@" : '';
         my $wait = $self->{lei}->{sto}->wq_do('done');
-        $ar->join;
-        $lei->child_error($?) if $?;
+        $lei->child_error($?, "@$cmd failed$err") if $err || $?;
         $self; # we are the mset (and $ibx, and $self)
 }