]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei_auth: trim and remove leftover worker code
authorEric Wong <e@80x24.org>
Mon, 22 Feb 2021 11:22:59 +0000 (08:22 -0300)
committerEric Wong <e@80x24.org>
Mon, 22 Feb 2021 22:14:23 +0000 (18:14 -0400)
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
lib/PublicInbox/LeiAuth.pm
lib/PublicInbox/LeiImport.pm
lib/PublicInbox/LeiQuery.pm

index dd34c66879fd9c4a08f0c9445c9c24d45afd5add..415a425deaf34a89d2ba44d8322e27cfb294fe82 100644 (file)
@@ -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 ($$) {
index b4777114f58ffa8f1899d9c770fb3c57ab783961..099bdaca2a1fc454dc3770064c4d8ede7b7a38d4 100644 (file)
@@ -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;
index bc37c6287059237feee33e16e7d072b5b7bd21c0..b85f4d6c457453aba2165f31d6b829dbd1889133 100644 (file)
@@ -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);
 }
index 64c9394c6186def834c976371b759c29b367245d..214267ee76ca87ebad553afc09724dd25ed170f8 100644 (file)
@@ -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);
 }