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,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE 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 6EBD71F487 for ; Thu, 2 Nov 2023 09:35:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1698917741; bh=nFQARc6RT8WVYbMi8IBACz9AY2CczLFufzohWR8YRPM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PSyWazL1OEZreESDPeHIW4ACKduDpCDHhHb1UVn85+imiC6Vrync+SoFac2NpBV1M +RDCnW78zi3oWwMgidILgCDnH9DI9flBomi2oQpXzYBLabXRrfi8JAwdlTGsYxArIS om6OSW+vHrQpWC1q92oNp6F3yTCsufd86oCFH4dI= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 03/14] treewide: use ->close method rather than CORE::close Date: Thu, 2 Nov 2023 09:35:28 +0000 Message-Id: <20231102093539.2067470-4-e@80x24.org> In-Reply-To: <20231102093539.2067470-1-e@80x24.org> References: <20231102093539.2067470-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: It's easier-to-read and should open the door for us to get rid of `tie' for ProcessIO without performance penalties for more frequently-used perlop calls and ability to do `stat' directly on the object instead of the awkward `tied' thing. --- lib/PublicInbox/CodeSearchIdx.pm | 6 +++--- lib/PublicInbox/DS.pm | 4 ++-- lib/PublicInbox/DirIdle.pm | 2 +- lib/PublicInbox/Git.pm | 6 +++--- lib/PublicInbox/HTTP.pm | 4 ++-- lib/PublicInbox/LeiMirror.pm | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/PublicInbox/CodeSearchIdx.pm b/lib/PublicInbox/CodeSearchIdx.pm index bf410734..c1a1ee90 100644 --- a/lib/PublicInbox/CodeSearchIdx.pm +++ b/lib/PublicInbox/CodeSearchIdx.pm @@ -480,11 +480,11 @@ sub partition_refs ($$$) { $seen = 0; } if ($DO_QUIT) { - CORE::close($rfh); + $rfh->close; return (); } } - CORE::close($rfh); + $rfh->close; return () if $DO_QUIT; if (!$? || (($? & 127) == POSIX::SIGPIPE && $seen > $SEEN_MAX)) { my $n = $NCHANGE - $n0; @@ -887,7 +887,7 @@ sub associate { ++$score{"$ibx_id $_"} for @root_ids; } } - CORE::close $rd or die "@join failed: $?=$?"; + $rd->close or die "fatal: @join failed: \$?=$?"; my $min = $self->{-opt}->{'assoc-min'} // 10; progress($self, scalar(keys %score).' potential pairings...'); for my $k (keys %score) { diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index 8331da95..33f80087 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -341,8 +341,8 @@ sub greet { my $ev = EPOLLIN; my $wbuf; if ($sock->can('accept_SSL') && !$sock->accept_SSL) { - return CORE::close($sock) if $! != EAGAIN; - $ev = PublicInbox::TLS::epollbit() or return CORE::close($sock); + return $sock->close if $! != EAGAIN; + $ev = PublicInbox::TLS::epollbit() or return $sock->close; $wbuf = [ \&accept_tls_step, $self->can('do_greet')]; } new($self, $sock, $ev | EPOLLONESHOT); diff --git a/lib/PublicInbox/DirIdle.pm b/lib/PublicInbox/DirIdle.pm index de6f229b..e6a326ab 100644 --- a/lib/PublicInbox/DirIdle.pm +++ b/lib/PublicInbox/DirIdle.pm @@ -89,7 +89,7 @@ sub force_close { my ($self) = @_; my $inot = delete $self->{inot} // return; if ($inot->can('fh')) { # Linux::Inotify2 2.3+ - CORE::close($inot->fh) or warn "CLOSE ERROR: $!"; + $inot->fh->close or warn "CLOSE ERROR: $!"; } elsif ($inot->isa('Linux::Inotify2')) { require PublicInbox::LI2Wrap; PublicInbox::LI2Wrap::wrapclose($inot); diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 191e4eea..3dac32be 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -441,12 +441,12 @@ sub qx { my $fh = popen(@_); if (wantarray) { my @ret = <$fh>; - CORE::close $fh; # caller should check $? + $fh->close; # caller should check $? @ret; } else { local $/; my $ret = <$fh>; - CORE::close $fh; # caller should check $? + $fh->close; # caller should check $? $ret; } } @@ -621,7 +621,7 @@ sub manifest_entry { } } $ent->{fingerprint} = sha_all(1, $sr)->hexdigest; - CORE::close $sr or return; # empty, uninitialized git repo + $sr->close or return; # empty, uninitialized git repo $ent->{modified} = modified(undef, $mod); chomp($buf = <$own> // ''); utf8::decode($buf); diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm index edc88fe8..85991ae7 100644 --- a/lib/PublicInbox/HTTP.pm +++ b/lib/PublicInbox/HTTP.pm @@ -63,8 +63,8 @@ sub new ($$$) { my $ev = EPOLLIN; my $wbuf; if ($sock->can('accept_SSL') && !$sock->accept_SSL) { - return CORE::close($sock) if $! != EAGAIN; - $ev = PublicInbox::TLS::epollbit() or return CORE::close($sock); + return $sock->close if $! != EAGAIN; + $ev = PublicInbox::TLS::epollbit() or return $sock->close; $wbuf = [ \&PublicInbox::DS::accept_tls_step ]; } $self->{wbuf} = $wbuf if $wbuf; diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index 0f378768..71f41a11 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -334,7 +334,7 @@ sub fgrp_update { upr($lei, $w, 'create', $ref, $oid); } } - CORE::close($w) or upref_warn(); + $w->close or upref_warn(); } sub satellite_done { @@ -344,7 +344,7 @@ sub satellite_done { while (my ($ref, $oid) = each %$create) { upr($fgrp->{lei}, $w, 'create', $ref, $oid); } - CORE::close($w) or upref_warn(); + $w->close or upref_warn(); } else { pack_refs($fgrp, $fgrp->{cur_dst}); run_puh($fgrp);