From fa5650d399f51a596e5c126b3ce65347409d4fe9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 22 Feb 2021 08:22:56 -0300 Subject: lei q: reduce wasted IMAP connection for auth We can rework the first lei2mail worker to authenticate, and then share auth info with the rest of the lei2mail workers. As with "lei import", this uses PktOp and lei-daemon to share updated credentials between the first an subsequent l2m workers. --- lib/PublicInbox/LeiAuth.pm | 37 ------------------------------------- 1 file changed, 37 deletions(-) (limited to 'lib/PublicInbox/LeiAuth.pm') diff --git a/lib/PublicInbox/LeiAuth.pm b/lib/PublicInbox/LeiAuth.pm index d329eadb..b4777114 100644 --- a/lib/PublicInbox/LeiAuth.pm +++ b/lib/PublicInbox/LeiAuth.pm @@ -20,13 +20,6 @@ sub net_merge { } } -sub do_auth { # called via wq_io_do - my ($self) = @_; - my ($lei, $net) = @$self{qw(lei net)}; - $net->imap_common_init($lei); - net_merge($lei, $net); # tell lei-daemon updated auth info -} - sub do_auth_atfork { # used by IPC WQ workers my ($self, $wq) = @_; return if $wq->{-wq_worker_nr} != 0; @@ -63,36 +56,6 @@ sub op_merge { # prepares PktOp->pair ops $ops->{net_merge_done1} = [ \&net_merge_done1, $wq ]; } -sub do_finish_auth { # dwaitpid callback - my ($arg, $pid) = @_; - my ($self, $lei, $post_auth_cb, @args) = @$arg; - $? ? $lei->dclose : $post_auth_cb->(@args); -} - -sub auth_eof { - my ($lei, $post_auth_cb, @args) = @_; - my $self = delete $lei->{auth} or return; - $self->wq_wait_old(\&do_finish_auth, $lei, $post_auth_cb, @args); -} - -sub auth_start { - my ($self, $lei, $post_auth_cb, @args) = @_; - my $op = $lei->workers_start($self, 'auth', 1, { - 'net_merge' => [ \&net_merge, $lei ], - '' => [ \&auth_eof, $lei, $post_auth_cb, @args ], - }); - $self->wq_io_do('do_auth', []); - $self->wq_close(1); - while ($op && $op->{sock}) { $op->event_step } -} - -sub ipc_atfork_child { - my ($self) = @_; - delete $self->{lei}->{auth}; # drop circular ref - $self->{lei}->lei_atfork_child; - $self->SUPER::ipc_atfork_child; -} - sub new { my ($cls, $net) = @_; # net may be NetReader or descendant (NetWriter) bless { net => $net }, $cls; -- cgit v1.2.3-24-ge0c7