]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: lock worker counts
authorEric Wong <e@80x24.org>
Sat, 18 Sep 2021 09:33:24 +0000 (09:33 +0000)
committerEric Wong <e@80x24.org>
Sat, 18 Sep 2021 20:25:25 +0000 (20:25 +0000)
It doesn't seem worthwhile to change worker counts dynamically
on a per-command-basis with lei, and I don't know how such an
interface would even work...

lib/PublicInbox/LEI.pm
lib/PublicInbox/LeiExportKw.pm
lib/PublicInbox/LeiImport.pm
lib/PublicInbox/LeiLsMailSource.pm
lib/PublicInbox/LeiLsSearch.pm
lib/PublicInbox/LeiRefreshMailSync.pm
lib/PublicInbox/LeiRm.pm
lib/PublicInbox/LeiTag.pm

index 9794497b6e3e03a4612a139d7f37f335bb673b49..41e761f8aabf939e81af2afb0b82bf7058b83e5e 100644 (file)
@@ -258,7 +258,7 @@ our %CMD = ( # sorted in order of importance/use:
         @c_opt ],
 'import' => [ 'LOCATION...|--stdin',
        'one-time import/update from URL or filesystem',
-       qw(stdin| offset=i recursive|r exclude=s include|I=s jobs=s new-only
+       qw(stdin| offset=i recursive|r exclude=s include|I=s new-only
        lock=s@ in-format|F=s kw! verbose|v+ incremental! mail-sync!),
        @net_opt, @c_opt ],
 'forget-mail-sync' => [ 'LOCATION...',
@@ -627,6 +627,7 @@ sub workers_start {
        my $end = $lei->pkt_op_pair;
        my $ident = $wq->{-wq_ident} // "lei-$lei->{cmd} worker";
        $flds->{lei} = $lei;
+       $wq->{-wq_nr_workers} //= $jobs; # lock, no incrementing
        $wq->wq_workers_start($ident, $jobs, $lei->oldset, $flds);
        delete $lei->{pkt_op_p};
        my $op_c = delete $lei->{pkt_op_c};
index d37f3768202619d434060981580ae27b0d2a76e0..8b8aa373a37199c1705835f8deb254c7e43f0f5b 100644 (file)
@@ -124,7 +124,6 @@ EOM
        my $ops = {};
        $sto->write_prepare($lei);
        $lei->{auth}->op_merge($ops, $self) if $lei->{auth};
-       $self->{-wq_nr_workers} = $j // 1; # locked
        (my $op_c, $ops) = $lei->workers_start($self, $j, $ops);
        $lei->{wq1} = $self;
        $lei->{-err_type} = 'non-fatal';
index 7c563bd8c8e79e864325cd0833e88d59406a120e..b1cb3940ee365cfe7f65e26585b53658cb576ea8 100644 (file)
@@ -101,7 +101,6 @@ sub do_import_index ($$@) {
        }
        my $ops = {};
        $lei->{auth}->op_merge($ops, $self) if $lei->{auth};
-       $self->{-wq_nr_workers} = $j // 1; # locked
        $lei->{-eml_noisy} = 1;
        (my $op_c, $ops) = $lei->workers_start($self, $j, $ops);
        $lei->{wq1} = $self;
index f012e10e89c2d10a71da50414be285ebe4a65d0f..bcb1838e9e689401fefb8913cb2ccbd80d8dc06e 100644 (file)
@@ -96,8 +96,7 @@ sub lei_ls_mail_source {
        $lei->start_pager if -t $lei->{1};
        my $ops = {};
        $lei->{auth}->op_merge($ops, $self);
-       my $j = $self->{-wq_nr_workers} = 1; # locked
-       (my $op_c, $ops) = $lei->workers_start($self, $j, $ops);
+       (my $op_c, $ops) = $lei->workers_start($self, 1, $ops);
        $lei->{wq1} = $self;
        $lei->{-err_type} = 'non-fatal';
        net_merge_all_done($self) unless $lei->{auth};
index 7013613523e33acfcfcfadc305bf136302756e68..aebf018429d3949ca9e2de8704d8ce680604e7f0 100644 (file)
@@ -71,7 +71,7 @@ sub do_ls_search_long {
 
 sub bg_worker ($$$) {
        my ($lei, $pfx, $json) = @_;
-       my $self = bless { -wq_nr_workers => 1, json => $json }, __PACKAGE__;
+       my $self = bless { json => $json }, __PACKAGE__;
        my ($op_c, $ops) = $lei->workers_start($self, 1);
        $lei->{wq1} = $self;
        $self->wq_io_do('do_ls_search_long', [], $pfx);
index 09a7ead06a0a43c1078b93816a826aa5a3019516..cdd997253a609dc5871bdb7e9b17c88aa1468bce 100644 (file)
@@ -84,11 +84,9 @@ EOM
        my $self = bless { missing_ok => 1 }, __PACKAGE__;
        $lei->{opt}->{'mail-sync'} = 1; # for prepare_inputs
        $self->prepare_inputs($lei, \@folders) or return;
-       my $j = $lei->{opt}->{jobs} || scalar(@{$self->{inputs}}) || 1;
        my $ops = {};
        $lei->{auth}->op_merge($ops, $self) if $lei->{auth};
-       $self->{-wq_nr_workers} = $j // 1; # locked
-       (my $op_c, $ops) = $lei->workers_start($self, $j, $ops);
+       (my $op_c, $ops) = $lei->workers_start($self, 1, $ops);
        $lei->{wq1} = $self;
        $lei->{-err_type} = 'non-fatal';
        net_merge_all_done($self) unless $lei->{auth};
index 778fa1de92763a14e49ff2e917048ecc86bb2a37..3371f3ed00e469f66233567ff50c782532514a92 100644 (file)
@@ -32,7 +32,7 @@ sub lei_rm {
        my ($lei, @inputs) = @_;
        $lei->_lei_store(1)->write_prepare($lei);
        $lei->{opt}->{'in-format'} //= 'eml';
-       my $self = bless { -wq_nr_workers => 1 }, __PACKAGE__;
+       my $self = bless {}, __PACKAGE__;
        $self->prepare_inputs($lei, \@inputs) or return;
        my ($op_c, $ops) = $lei->workers_start($self, 1);
        $lei->{wq1} = $self;
index 44d77b881c04136c1f190e3e166298e100fd101c..c4f5ecffb575168044b216139874e2d8a14c5e2d 100644 (file)
@@ -50,8 +50,7 @@ sub lei_tag { # the "lei tag" method
                return $lei->fail('no keywords or labels specified');
        my $ops = {};
        $lei->{auth}->op_merge($ops, $self) if $lei->{auth};
-       my $j = $self->{-wq_nr_workers} = 1; # locked for now
-       (my $op_c, $ops) = $lei->workers_start($self, $j, $ops);
+       (my $op_c, $ops) = $lei->workers_start($self, 1, $ops);
        $lei->{wq1} = $self;
        $lei->{-err_type} = 'non-fatal';
        net_merge_all_done($self) unless $lei->{auth};