From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH 4/4] lei_{input,remote}: drop AutoReap usage for curl
Date: Sun, 8 Oct 2023 11:45:34 +0000 [thread overview]
Message-ID: <20231008114534.274616-4-e@80x24.org> (raw)
In-Reply-To: <20231008114534.274616-1-e@80x24.org>
We can use ProcessIO directly and just close synchronously
now that ProcessIO->BINMODE works properly.
---
lib/PublicInbox/LeiInput.pm | 11 +++++------
lib/PublicInbox/LeiRemote.pm | 13 +++++--------
2 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/lib/PublicInbox/LeiInput.pm b/lib/PublicInbox/LeiInput.pm
index 93f8b6b8..4fd50416 100644
--- a/lib/PublicInbox/LeiInput.pm
+++ b/lib/PublicInbox/LeiInput.pm
@@ -7,7 +7,6 @@ use v5.12;
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
@@ -114,14 +113,14 @@ sub handle_http_input ($$@) {
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} });
+ my $cfh;
grep(/\A--compressed\z/, @$curl) or
- $fh = IO::Uncompress::Gunzip->new($fh, MultiStream => 1);
+ $fh = IO::Uncompress::Gunzip->new($cfh = $fh, MultiStream => 1);
eval { $self->input_fh('mboxrd', $fh, $url, @args) };
my @err = ($@ ? $@ : ());
- $ar->join;
- push(@err, "\$?=$?") if $?;
+ close $cfh if $cfh;
+ push(@err, "\$?=$?") if $?; # MboxReader closes
$lei->child_error($?, "@$cmd failed: @err") if @err;
}
diff --git a/lib/PublicInbox/LeiRemote.pm b/lib/PublicInbox/LeiRemote.pm
index 15013baa..4b65997b 100644
--- a/lib/PublicInbox/LeiRemote.pm
+++ b/lib/PublicInbox/LeiRemote.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# Make remote externals HTTP(S) inboxes behave like
@@ -6,13 +6,11 @@
# This exists solely for SolverGit. It is a high-latency a
# synchronous API that is not at all fast.
package PublicInbox::LeiRemote;
-use v5.10.1;
-use strict;
+use v5.12;
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 {
@@ -47,13 +45,12 @@ 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);
+ my $cfh = popen_rd($cmd, undef, { 2 => $lei->{2} });
$self->{smsg} = [];
- $fh = IO::Uncompress::Gunzip->new($fh, MultiStream => 1);
+ my $fh = IO::Uncompress::Gunzip->new($cfh, MultiStream => 1);
PublicInbox::MboxReader->mboxrd($fh, \&_each_mboxrd_eml, $self);
$self->{lei}->sto_done_request;
- $ar->join;
+ close $cfh;
$lei->child_error($?) if $?;
$self; # we are the mset (and $ibx, and $self)
}
prev parent reply other threads:[~2023-10-08 11:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-08 11:45 [PATCH 1/4] process_io: fix binmode and use it in lei_xsearch for curl Eric Wong
2023-10-08 11:45 ` [PATCH 2/4] lei rediff: use ProcessIO for --drq support Eric Wong
2023-10-08 11:45 ` [PATCH 3/4] lei_xsearch: improve curl progress reporting Eric Wong
2023-10-08 11:45 ` Eric Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231008114534.274616-4-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).