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 9A1021F566 for ; Fri, 22 Sep 2023 21:13:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1695417196; bh=6Icypvw13E9s4POw8Quj0oanLP4jG8jSSyzSPYD4C9o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=frH7B3d0EyM8lYXWTy0yPwng+74RdbX6v61dak25RXWH8bNx65/sHr1LZlzlPYXGH T7QCWE1ff08kQkOan+5awh8YLK7RPwk7SZNLflnIgnT0IlHyrYkZ5Ktl0jj50qZHEN fhFH1zEvnsNHHSqGRJ7D/bOLHUg1jbac9N3dIJZ0= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/4] lei_to_mail: drop awkward duplication of $lei object Date: Fri, 22 Sep 2023 21:13:15 +0000 Message-ID: <20230922211316.3060039-4-e@80x24.org> In-Reply-To: <20230922211316.3060039-1-e@80x24.org> References: <20230922211316.3060039-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Our awaitpid API now exists and ProcessPipe uses it, so it's immune to cyclic references. Thus there's no need to create a duplicate of the lei object to prevent leaks. --- lib/PublicInbox/LeiToMail.pm | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm index 7c7967c8..4adcc33e 100644 --- a/lib/PublicInbox/LeiToMail.pm +++ b/lib/PublicInbox/LeiToMail.pm @@ -151,10 +151,9 @@ sub git_to_mail { # git->cat_async callback } sub reap_compress { # awaitpid callback - my ($pid, $lei) = @_; - my $cmd = delete $lei->{"pid.$pid"}; - return if $? == 0; - $lei->fail($?, "@$cmd failed"); + my ($pid, $lei, $cmd, $old_out) = @_; + $lei->{1} = $old_out; + $lei->fail($?, "@$cmd failed") if $?; } sub _post_augment_mbox { # open a compressor process from top-level process @@ -165,9 +164,8 @@ sub _post_augment_mbox { # open a compressor process from top-level process my $rdr = { 0 => $r, 1 => $lei->{1}, 2 => $lei->{2}, pgid => 0 }; my $pid = spawn($cmd, undef, $rdr); my $pp = gensym; - my $dup = bless { "pid.$pid" => $cmd }, ref($lei); - $dup->{$_} = $lei->{$_} for qw(2 sock); - tie *$pp, 'PublicInbox::ProcessPipe', $pid, $w, \&reap_compress, $dup; + tie *$pp, 'PublicInbox::ProcessPipe', $pid, $w, + \&reap_compress, $lei, $cmd, $lei->{1}; $lei->{1} = $pp; }