From 7f05ec260f2a8e81c884a1461f1573c1b7edef12 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 1 Oct 2023 09:54:17 +0000 Subject: gcf2: take non-ref scalar request arg 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. --- lib/PublicInbox/Gcf2Client.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/PublicInbox/Gcf2Client.pm') 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 -- cgit v1.2.3-24-ge0c7