From: Eric Wong <e@80x24.org>
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 [thread overview]
Message-ID: <20210222112259.32402-2-e@80x24.org> (raw)
In-Reply-To: <20210222112259.32402-1-e@80x24.org>
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;
}
next prev parent reply other threads:[~2021-02-22 11:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-22 11:21 [PATCH 00/10] lei: avoid wasting IMAP connections Eric Wong
2021-02-22 11:22 ` [PATCH 01/10] lei_auth: rename {nrd} field to {net} for clarity Eric Wong
2021-02-22 11:22 ` Eric Wong [this message]
2021-02-22 11:22 ` [PATCH 03/10] lei: _lei_cfg: return empty hashref if unconfigured Eric Wong
2021-02-22 11:22 ` [PATCH 04/10] lei convert: auth directly from worker process Eric Wong
2021-02-22 11:22 ` [PATCH 05/10] lei import: no separate auth worker Eric Wong
2021-02-22 11:22 ` [PATCH 06/10] lei_auth: migrate common auth code from lei_import Eric Wong
2021-02-22 11:22 ` [PATCH 07/10] lei q: reduce wasted IMAP connection for auth Eric Wong
2021-02-22 11:22 ` [PATCH 08/10] net_reader: mic_get: reuse connections if cache enabled Eric Wong
2021-02-22 11:22 ` [PATCH 09/10] lei convert: inline convert_start Eric Wong
2021-02-22 11:22 ` [PATCH 10/10] lei_auth: trim and remove leftover worker code Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210222112259.32402-2-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).