about summary refs log tree commit homepage
path: root/lib/PublicInbox
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-10-01 09:54:17 +0000
committerEric Wong <e@80x24.org>2023-10-01 22:41:40 +0000
commit7f05ec260f2a8e81c884a1461f1573c1b7edef12 (patch)
treedf336a57c79368beb9881294cdee167402b3cbe3 /lib/PublicInbox
parent3f5ac9b00bc95de4a5f4f06266d3a2eb5424e24a (diff)
downloadpublic-inbox-7f05ec260f2a8e81c884a1461f1573c1b7edef12.tar.gz
Asking callers to pass a scalar reference is awkward and
doesn't benefit modern Perl with CoW support.  Unlike
some constant error messages, it can't save any allocations
at all since there's no constant strings being passed to
libgit2.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r--lib/PublicInbox/Gcf2Client.pm8
-rw-r--r--lib/PublicInbox/GitAsyncCat.pm4
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/PublicInbox/Gcf2Client.pm b/lib/PublicInbox/Gcf2Client.pm
index 8ac44a5e..8e313c84 100644
--- a/lib/PublicInbox/Gcf2Client.pm
+++ b/lib/PublicInbox/Gcf2Client.pm
@@ -11,6 +11,7 @@ use PublicInbox::Spawn qw(spawn);
 use Socket qw(AF_UNIX SOCK_STREAM);
 use PublicInbox::Syscall qw(EPOLLIN);
 use PublicInbox::ProcessPipe;
+use autodie qw(socketpair);
 
 # fields:
 #        sock => socket to Gcf2::loop
@@ -26,8 +27,7 @@ sub new  {
         my $self = bless {}, __PACKAGE__;
         # ensure the child process has the same @INC we do:
         my $env = { PERL5LIB => join(':', @INC) };
-        my ($s1, $s2);
-        socketpair($s1, $s2, AF_UNIX, SOCK_STREAM, 0) or die "socketpair $!";
+        socketpair(my $s1, my $s2, AF_UNIX, SOCK_STREAM, 0);
         $s1->blocking(0);
         $opt->{0} = $opt->{1} = $s2;
         my $cmd = [$^X, qw[-MPublicInbox::Gcf2 -e PublicInbox::Gcf2::loop]];
@@ -41,8 +41,8 @@ sub new  {
 sub gcf2_async ($$$;$) {
         my ($self, $req, $cb, $arg) = @_;
         my $inflight = $self->{inflight} or return $self->close;
-        PublicInbox::Git::write_all($self, $$req, \&cat_async_step, $inflight);
-        push @$inflight, $req, $cb, $arg;
+        PublicInbox::Git::write_all($self, $req, \&cat_async_step, $inflight);
+        push @$inflight, \$req, $cb, $arg; # ref prevents Git.pm retries
 }
 
 # ensure PublicInbox::Git::cat_async_step never calls cat_async_retry
diff --git a/lib/PublicInbox/GitAsyncCat.pm b/lib/PublicInbox/GitAsyncCat.pm
index 71ee1147..f8b2a9fc 100644
--- a/lib/PublicInbox/GitAsyncCat.pm
+++ b/lib/PublicInbox/GitAsyncCat.pm
@@ -18,7 +18,7 @@ sub ibx_async_cat ($$$$) {
                 require PublicInbox::Gcf2Client;
                 PublicInbox::Gcf2Client::new();
         } // 0)) { # 0: do not retry if libgit2 or Inline::C are missing
-                $GCF2C->gcf2_async(\"$oid $git->{git_dir}\n", $cb, $arg);
+                $GCF2C->gcf2_async("$oid $git->{git_dir}\n", $cb, $arg);
                 \undef;
         } else { # read-only end of git-cat-file pipe
                 $git->cat_async($oid, $cb, $arg);
@@ -42,7 +42,7 @@ sub ibx_async_prefetch {
         if (!defined($ibx->{topdir}) && $GCF2C) {
                 if (!@{$GCF2C->{inflight} // []}) {
                         $oid .= " $git->{git_dir}\n";
-                        return $GCF2C->gcf2_async(\$oid, $cb, $arg); # true
+                        return $GCF2C->gcf2_async($oid, $cb, $arg); # true
                 }
         } elsif ($git->{epwatch}) {
                 return $git->async_prefetch($oid, $cb, $arg);