about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiAuth.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-02-18 23:22:24 +0300
committerEric Wong <e@80x24.org>2021-02-18 20:02:20 -0400
commitd972b6711b01500181f809ef54a08aa29cb0d4a4 (patch)
tree485a06a9bf3eef48fe1ab24f7ba6c1cac78f9df5 /lib/PublicInbox/LeiAuth.pm
parent46eac797d44b068a5e144ecc8269e9dbe878f495 (diff)
downloadpublic-inbox-d972b6711b01500181f809ef54a08aa29cb0d4a4.tar.gz
The backends for "lei add-external --mirror", "lei convert", and
"lei import" all share a similar pattern for spawning background
workers.  Hoist out the common parts to slim down our code base
a bit.

The LeiXSearch and LeiToMail workers for "lei q" remains a the
odd duck due to the deep pipelining and parallelization.
Diffstat (limited to 'lib/PublicInbox/LeiAuth.pm')
-rw-r--r--lib/PublicInbox/LeiAuth.pm17
1 files changed, 3 insertions, 14 deletions
diff --git a/lib/PublicInbox/LeiAuth.pm b/lib/PublicInbox/LeiAuth.pm
index 6593ba51..7acb9900 100644
--- a/lib/PublicInbox/LeiAuth.pm
+++ b/lib/PublicInbox/LeiAuth.pm
@@ -43,24 +43,13 @@ sub auth_eof {
 sub auth_start {
         my ($self, $lei, $post_auth_cb, @args) = @_;
         $lei->_lei_cfg(1); # workers may need to read config
-        my $ops = {
-                '!' => [ $lei->can('fail_handler'), $lei ],
-                '|' => [ $lei->can('sigpipe_handler'), $lei ],
-                'x_it' => [ $lei->can('x_it'), $lei ],
-                'child_error' => [ $lei->can('child_error'), $lei ],
+        my $op = $lei->workers_start($self, 'auth', 1, {
                 'nrd_merge' => [ \&nrd_merge, $lei ],
                 '' => [ \&auth_eof, $lei, $post_auth_cb, @args ],
-        };
-        ($lei->{pkt_op_c}, $lei->{pkt_op_p}) = PublicInbox::PktOp->pair($ops);
-        $self->wq_workers_start('lei_auth', 1, $lei->oldset, {lei => $lei});
-        my $op = delete $lei->{pkt_op_c};
-        delete $lei->{pkt_op_p};
+        });
         $self->wq_io_do('do_auth', []);
         $self->wq_close(1);
-        $lei->event_step_init; # wait for shutdowns
-        if ($lei->{oneshot}) {
-                while ($op->{sock}) { $op->event_step }
-        }
+        while ($op && $op->{sock}) { $op->event_step }
 }
 
 sub ipc_atfork_child {