about summary refs log tree commit homepage
path: root/lib/PublicInbox/Gcf2Client.pm
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/Gcf2Client.pm
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/Gcf2Client.pm')
-rw-r--r--lib/PublicInbox/Gcf2Client.pm8
1 files changed, 4 insertions, 4 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