user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 10/10] lei_auth: trim and remove leftover worker code
Date: Mon, 22 Feb 2021 08:22:59 -0300	[thread overview]
Message-ID: <20210222112259.32402-10-e@80x24.org> (raw)
In-Reply-To: <20210222112259.32402-1-e@80x24.org>

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);
 }

      parent reply	other threads:[~2021-02-22 11:23 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   ` [PATCH 02/10] lei: keep client {sock} in short-lived workers Eric Wong
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   ` Eric Wong [this message]

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-10-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    --subject='Re: [PATCH 10/10] lei_auth: trim and remove leftover worker code' \
    /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

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.mail.public-inbox.meta
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.mail.public-inbox.meta
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git