From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 8B7D11F9FE for ; Mon, 22 Feb 2021 11:22:59 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 02/10] lei: keep client {sock} in short-lived workers Date: Mon, 22 Feb 2021 08:22:51 -0300 Message-Id: <20210222112259.32402-2-e@80x24.org> In-Reply-To: <20210222112259.32402-1-e@80x24.org> References: <20210222112155.32231-1-e@80x24.org> <20210222112259.32402-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 | 4 ++-- lib/PublicInbox/LeiAuth.pm | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) 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; }