]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: keep client {sock} in short-lived workers
authorEric Wong <e@80x24.org>
Mon, 22 Feb 2021 11:22:51 +0000 (08:22 -0300)
committerEric Wong <e@80x24.org>
Mon, 22 Feb 2021 22:14:17 +0000 (18:14 -0400)
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.

lib/PublicInbox/LEI.pm
lib/PublicInbox/LeiAuth.pm

index 8d49b212baf677426857081d99ab83b0e7229673..73c9e267b1e4a37ef742f0e56b10d3655f6cf4b9 100644 (file)
@@ -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}) {
index c70d8e8fd5066118d65038b334db782b52d74cb4..f2cdb0260a766147fd3d08478ad13ad32755f758 100644 (file)
@@ -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;
 }