From: Eric Wong Date: Mon, 22 Feb 2021 11:22:51 +0000 (-0300) Subject: lei: keep client {sock} in short-lived workers X-Git-Tag: v1.7.0~1083 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=2fc7ac8bf713d10a77ed65ca9fa8836675d3a57f;p=public-inbox.git lei: keep client {sock} in short-lived workers For non-persistent workers, there's no harm in keeping the client socket open. This means we can avoid dancing around closing it in PublicInbox::LeiAuth::ipc_atfork_child. Eventually, other WQ workers will trigger "git credential" spawning in script/lei directly. --- diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 8d49b212..73c9e267 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -443,7 +443,7 @@ sub lei_atfork_child { my ($self, $persist) = @_; # we need to explicitly close things which are on stack if ($persist) { - my @io = delete @$self{0,1,2}; + my @io = delete @$self{qw(0 1 2 sock)}; unless ($self->{oneshot}) { close($_) for @io; } @@ -451,7 +451,7 @@ sub lei_atfork_child { delete $self->{0}; } delete @$self{qw(cnv)}; - for (delete @$self{qw(3 sock old_1 au_done)}) { + for (delete @$self{qw(3 old_1 au_done)}) { close($_) if defined($_); } if (my $op_c = delete $self->{pkt_op_c}) { diff --git a/lib/PublicInbox/LeiAuth.pm b/lib/PublicInbox/LeiAuth.pm index c70d8e8f..f2cdb026 100644 --- a/lib/PublicInbox/LeiAuth.pm +++ b/lib/PublicInbox/LeiAuth.pm @@ -54,11 +54,8 @@ sub auth_start { sub ipc_atfork_child { my ($self) = @_; - # prevent {sock} from being closed in lei_atfork_child: - my $s = delete $self->{lei}->{sock}; delete $self->{lei}->{auth}; # drop circular ref $self->{lei}->lei_atfork_child; - $self->{lei}->{sock} = $s if $s; $self->SUPER::ipc_atfork_child; }