From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id F0E201F487 for ; Sun, 8 Oct 2023 11:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1696765535; bh=YHKfzqLNqCS3BeOoIu4TJGH0B+IHeGnHeUQkZD+yDZw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qUpy+mo2UoZ0biC1Ct1pXE8c0d2jBNUDu7e6v6cCNqH3eBYJdrtesXYZcT58SsTpS 7vaYwPniOn5A71fpI7vt4GS1xP0orLTE+oz6VEmMXtezZPvnc2BUGIPHFtfKfV+rL4 bIcpl4jRxFHfb2fv+34DNwV+jP9jpp+s71HbHX6M= From: Eric Wong 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 Message-ID: <20231008114534.274616-4-e@80x24.org> In-Reply-To: <20231008114534.274616-1-e@80x24.org> References: <20231008114534.274616-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 +# Copyright (C) all contributors # License: AGPL-3.0+ # 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) }