* [PATCH 10/10] lei_auth: trim and remove leftover worker code
@ 2021-02-22 11:22 6% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-02-22 11:22 UTC (permalink / raw)
To: meta
LeiAuth is no longer a separate worker process. Instead, it's
used directly by LeiToMail and LeiImport for sharing auth info
from the first worker to the rest of the workers, using
lei-daemon as a message router. So drop the old code to reduce
human cognitive load and interpreter memory overhead.
---
lib/PublicInbox/LEI.pm | 2 +-
lib/PublicInbox/LeiAuth.pm | 24 +++++-------------------
lib/PublicInbox/LeiImport.pm | 2 +-
lib/PublicInbox/LeiQuery.pm | 4 ++--
4 files changed, 9 insertions(+), 23 deletions(-)
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index dd34c668..415a425d 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -324,7 +324,7 @@ my %CONFIG_KEYS = (
'leistore.dir' => 'top-level storage location',
);
-my @WQ_KEYS = qw(lxs l2m imp mrr cnv auth); # internal workers
+my @WQ_KEYS = qw(lxs l2m imp mrr cnv); # internal workers
# pronounced "exit": x_it(1 << 8) => exit(1); x_it(13) => SIGPIPE
sub x_it ($$) {
diff --git a/lib/PublicInbox/LeiAuth.pm b/lib/PublicInbox/LeiAuth.pm
index b4777114..099bdaca 100644
--- a/lib/PublicInbox/LeiAuth.pm
+++ b/lib/PublicInbox/LeiAuth.pm
@@ -6,27 +6,16 @@
package PublicInbox::LeiAuth;
use strict;
use v5.10.1;
-use parent qw(PublicInbox::IPC);
use PublicInbox::PktOp qw(pkt_do);
-sub net_merge {
- my ($lei, $net_new) = @_;
- if ($lei->{pkt_op_p}) { # from lei_convert worker
- pkt_do($lei->{pkt_op_p}, 'net_merge', $net_new);
- } else { # single lei-daemon consumer
- my $self = $lei->{auth} or return; # client disconnected
- my $net = $self->{net};
- %$net = (%$net, %$net_new);
- }
-}
-
sub do_auth_atfork { # used by IPC WQ workers
my ($self, $wq) = @_;
return if $wq->{-wq_worker_nr} != 0;
my $lei = $wq->{lei};
- my $net = $self->{net};
+ my $net = $lei->{net};
my $mics = $net->imap_common_init($lei);
- net_merge($lei, $net);
+ pkt_do($lei->{pkt_op_p}, 'net_merge', $net) or
+ die "pkt_do net_merge: $!";
$net->{mics_cached} = $mics;
}
@@ -36,7 +25,7 @@ sub net_merge_done1 { # bump merge-count in top-level lei-daemon
$wq->net_merge_complete; # defined per wq-class (e.g. LeiImport)
}
-sub net_merge_all { # called via wq_broadcast
+sub net_merge_all { # called in wq worker via wq_broadcast
my ($wq, $net_new) = @_;
my $net = $wq->{lei}->{net};
%$net = (%$net, %$net_new);
@@ -56,9 +45,6 @@ sub op_merge { # prepares PktOp->pair ops
$ops->{net_merge_done1} = [ \&net_merge_done1, $wq ];
}
-sub new {
- my ($cls, $net) = @_; # net may be NetReader or descendant (NetWriter)
- bless { net => $net }, $cls;
-}
+sub new { bless \(my $x), __PACKAGE__ }
1;
diff --git a/lib/PublicInbox/LeiImport.pm b/lib/PublicInbox/LeiImport.pm
index bc37c628..b85f4d6c 100644
--- a/lib/PublicInbox/LeiImport.pm
+++ b/lib/PublicInbox/LeiImport.pm
@@ -112,7 +112,7 @@ sub call { # the main "lei import" method
$net->{quiet} = $lei->{opt}->{quiet};
$lei->{net} = $net;
require PublicInbox::LeiAuth;
- $lei->{auth} = PublicInbox::LeiAuth->new($net);
+ $lei->{auth} = PublicInbox::LeiAuth->new;
}
import_start($lei);
}
diff --git a/lib/PublicInbox/LeiQuery.pm b/lib/PublicInbox/LeiQuery.pm
index 64c9394c..214267ee 100644
--- a/lib/PublicInbox/LeiQuery.pm
+++ b/lib/PublicInbox/LeiQuery.pm
@@ -13,9 +13,9 @@ sub prep_ext { # externals_each callback
sub _start_query {
my ($self) = @_;
- if (my $net = $self->{net}) {
+ if ($self->{net}) {
require PublicInbox::LeiAuth;
- $self->{auth} = PublicInbox::LeiAuth->new($net);
+ $self->{auth} = PublicInbox::LeiAuth->new
}
$self->{lxs}->do_query($self);
}
^ permalink raw reply related [relevance 6%]
* [PATCH 00/10] lei: avoid wasting IMAP connections
@ 2021-02-22 11:21 7% Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-02-22 11:21 UTC (permalink / raw)
To: meta
This makes the code a bit less straightforward, unfortunately;
but I've tried to comment it a bit and add some flow notes.
The payoff is it saves IMAP connection setup costs which is
noticeable in high-latency and/or metered bandwidth situations.
LeiAuth is signficantly rewritten so it uses lei-daemon
to route credentials from the first worker to other workers.
Eric Wong (10):
lei_auth: rename {nrd} field to {net} for clarity
lei: keep client {sock} in short-lived workers
lei: _lei_cfg: return empty hashref if unconfigured
lei convert: auth directly from worker process
lei import: no separate auth worker
lei_auth: migrate common auth code from lei_import
lei q: reduce wasted IMAP connection for auth
net_reader: mic_get: reuse connections if cache enabled
lei convert: inline convert_start
lei_auth: trim and remove leftover worker code
lib/PublicInbox/LEI.pm | 8 ++--
lib/PublicInbox/LeiAuth.pm | 76 +++++++++++++---------------------
lib/PublicInbox/LeiConvert.pm | 36 +++++++---------
lib/PublicInbox/LeiExternal.pm | 6 +--
lib/PublicInbox/LeiImport.pm | 60 ++++++++++++++++-----------
lib/PublicInbox/LeiQuery.pm | 9 ++--
lib/PublicInbox/LeiToMail.pm | 53 ++++++++++++++++--------
lib/PublicInbox/LeiXSearch.pm | 26 ++++++++----
lib/PublicInbox/NetReader.pm | 20 +++++----
lib/PublicInbox/NetWriter.pm | 2 +-
10 files changed, 158 insertions(+), 138 deletions(-)
^ permalink raw reply [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-02-22 11:21 7% [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 6% ` [PATCH 10/10] lei_auth: trim and remove leftover worker code Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
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).