diff options
author | Eric Wong <e@80x24.org> | 2021-04-28 07:52:02 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-04-28 19:30:58 +0000 |
commit | eee88c0967d741686e1d14a01bc34c55167213e4 (patch) | |
tree | 9876873bc9550c9327b1c1c35494299033c1d03f /lib/PublicInbox/LEI.pm | |
parent | 63e2751ace2dd35a661620a9ad30d6c92948a009 (diff) | |
download | public-inbox-eee88c0967d741686e1d14a01bc34c55167213e4.tar.gz |
This lets us share more code and reduces cognitive overhead when it comes to picking names (because {lsss} was ridiculous). We'll need to ensure the first error set in lei is the actual error we exit with, otherwise things can get confusing and errors may get lost.
Diffstat (limited to 'lib/PublicInbox/LEI.pm')
-rw-r--r-- | lib/PublicInbox/LEI.pm | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index cfbf12f0..403f9ed8 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -382,7 +382,7 @@ my %CONFIG_KEYS = ( 'leistore.dir' => 'top-level storage location', ); -my @WQ_KEYS = qw(lxs l2m imp mrr cnv p2q tag sol lsss); # internal workers +my @WQ_KEYS = qw(lxs l2m wq1); # internal workers sub _drop_wq { my ($self) = @_; @@ -542,7 +542,7 @@ sub workers_start { 'child_error' => [ \&child_error, $lei ], ($ops ? %$ops : ()), }; - $ops->{''} //= [ $wq->can('_lei_wq_eof') || \&dclose, $lei ]; + $ops->{''} //= [ $wq->can('_lei_wq_eof') || \&wq_eof, $lei ]; my $end = $lei->pkt_op_pair; $wq->wq_workers_start($ident, $jobs, $lei->oldset, { lei => $lei }); delete $lei->{pkt_op_p}; @@ -1237,9 +1237,17 @@ sub DESTROY { sub wq_done_wait { # dwaitpid callback my ($arg, $pid) = @_; - my ($wq, $lei, $e) = @$arg; - $? and $lei->child_error($?, $e ? "$e errors during $lei->{cmd}" : ()); + my ($wq, $lei) = @$arg; + my $err_type = $lei->{-err_type}; + $? and $lei->child_error($?, + $err_type ? "$err_type errors during $lei->{cmd}" : ()); $lei->dclose; } +sub wq_eof { # EOF callback for main daemon + my ($lei) = @_; + my $wq1 = delete $lei->{wq1} // return $lei->fail; # already failed + $wq1->wq_wait_old(\&wq_done_wait, $lei); +} + 1; |