use PublicInbox::DS;
use PublicInbox::Spawn qw(which popen_rd);
use PublicInbox::InboxWritable qw(eml_from_path);
-use PublicInbox::AutoReap;
# JMAP RFC 8621 4.1.1
# https://www.iana.org/assignments/imap-jmap-keywords/imap-jmap-keywords.xhtml
push @$curl, '-s', @$curl_opt;
my $cmd = $curl->for_uri($lei, $uri);
$lei->qerr("# $cmd");
- my ($fh, $pid) = popen_rd($cmd, undef, { 2 => $lei->{2} });
- my $ar = PublicInbox::AutoReap->new($pid);
+ my $fh = popen_rd($cmd, undef, { 2 => $lei->{2} });
grep(/\A--compressed\z/, @$curl) or
- $fh = IO::Uncompress::Gunzip->new($fh, MultiStream => 1);
+ $fh = IO::Uncompress::Gunzip->new($fh,
+ MultiStream => 1, AutoClose => 1);
eval { $self->input_fh('mboxrd', $fh, $url, @args) };
- my @err = ($@ ? $@ : ());
- $ar->join;
- push(@err, "\$?=$?") if $?;
- $lei->child_error($?, "@$cmd failed: @err") if @err;
+ my $err = $@ ? ": $@" : '';
+ $lei->child_error($?, "@$cmd failed$err") if $err || $?;
}
sub oid2eml { # git->cat_async cb
use PublicInbox::MboxReader;
use PublicInbox::Spawn qw(popen_rd);
use PublicInbox::LeiCurl;
-use PublicInbox::AutoReap;
use PublicInbox::ContentHash qw(git_sha);
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);
$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)
}
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);