lib/PublicInbox/LEI.pm | 9 +++++++++ lib/PublicInbox/LeiBlob.pm | 2 +- lib/PublicInbox/LeiConvert.pm | 2 +- lib/PublicInbox/LeiExportKw.pm | 2 +- lib/PublicInbox/LeiImport.pm | 3 +-- lib/PublicInbox/LeiLsSearch.pm | 2 +- lib/PublicInbox/LeiMirror.pm | 4 ++-- lib/PublicInbox/LeiP2q.pm | 4 ++-- lib/PublicInbox/LeiRediff.pm | 2 +- lib/PublicInbox/LeiRm.pm | 2 +- lib/PublicInbox/LeiTag.pm | 2 +- lib/PublicInbox/LeiXSearch.pm | 2 +- lib/PublicInbox/PktOp.pm | 6 ------ diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 0cf4d10b892b287eabbc6a14a50cb9d400791c00..ed01e8def7bf2754fd5130a04d900e111079a602 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -587,6 +587,15 @@ $lei->event_step_init; ($op_c, $ops); } +# call this when we're ready to wait on events and yield to other clients +sub wait_wq_events { + my ($lei, $op_c, $ops) = @_; + for my $wq (grep(defined, @$lei{qw(ikw)})) { # auxiliary WQs + $wq->wq_close(1); + } + $op_c->{ops} = $ops; +} + sub _help { require PublicInbox::LeiHelp; PublicInbox::LeiHelp::call($_[0], $_[1], \%CMD, \%OPTDESC); diff --git a/lib/PublicInbox/LeiBlob.pm b/lib/PublicInbox/LeiBlob.pm index 8de86565ab90ad7fb90c1ff385bb8d1b1364107d..0921796428b4254af4f07ed00a85ecd179a28652 100644 --- a/lib/PublicInbox/LeiBlob.pm +++ b/lib/PublicInbox/LeiBlob.pm @@ -169,7 +169,7 @@ my ($op_c, $ops) = $lei->workers_start($self, 1); $lei->{wq1} = $self; $self->wq_io_do('do_solve_blob', []); $self->wq_close(1); - $op_c->op_wait_event($ops); + $lei->wait_wq_events($op_c, $ops); } sub ipc_atfork_child { diff --git a/lib/PublicInbox/LeiConvert.pm b/lib/PublicInbox/LeiConvert.pm index 395a80f8adee44cb1a5d49f776f1573d174d3395..6550c242b1a2514ced857e2d956bfa0a8fdc0ad5 100644 --- a/lib/PublicInbox/LeiConvert.pm +++ b/lib/PublicInbox/LeiConvert.pm @@ -59,7 +59,7 @@ my ($op_c, $ops) = $lei->workers_start($self, 1); $lei->{wq1} = $self; $self->wq_io_do('process_inputs', []); $self->wq_close(1); - $op_c->op_wait_event($ops); + $lei->wait_wq_events($op_c, $ops); } sub ipc_atfork_child { diff --git a/lib/PublicInbox/LeiExportKw.pm b/lib/PublicInbox/LeiExportKw.pm index b31b065fe4f95fb062650a7218dc048a8f21c122..f8579221015e56d5fec023d8e6a5d5bc14257322 100644 --- a/lib/PublicInbox/LeiExportKw.pm +++ b/lib/PublicInbox/LeiExportKw.pm @@ -160,7 +160,7 @@ (my $op_c, $ops) = $lei->workers_start($self, $j, $ops); $lei->{wq1} = $self; $lei->{-err_type} = 'non-fatal'; net_merge_all_done($self) unless $lei->{auth}; - $op_c->op_wait_event($ops); # calls net_merge_all_done if $lei->{auth} + $lei->wait_wq_events($op_c, $ops); # net_merge_all_done if !{auth} } sub _complete_export_kw { diff --git a/lib/PublicInbox/LeiImport.pm b/lib/PublicInbox/LeiImport.pm index 2efd4935ab7d3d63d1c36460d054513205fed4c7..222f75c8abe1b0e5c9ebda30e68c9a3ca0f03a5e 100644 --- a/lib/PublicInbox/LeiImport.pm +++ b/lib/PublicInbox/LeiImport.pm @@ -91,9 +91,8 @@ $lei->{-eml_noisy} = 1; (my $op_c, $ops) = $lei->workers_start($self, $j, $ops); $lei->{wq1} = $self; $lei->{-err_type} = 'non-fatal'; - $ikw->wq_close(1) if $ikw; net_merge_all_done($self) unless $lei->{auth}; - $op_c->op_wait_event($ops); + $lei->wait_wq_events($op_c, $ops); } sub lei_import { # the main "lei import" method diff --git a/lib/PublicInbox/LeiLsSearch.pm b/lib/PublicInbox/LeiLsSearch.pm index 6cea6ae88089935d4f31a69bf9845ef8dad39dc4..7013613523e33acfcfcfadc305bf136302756e68 100644 --- a/lib/PublicInbox/LeiLsSearch.pm +++ b/lib/PublicInbox/LeiLsSearch.pm @@ -76,7 +76,7 @@ my ($op_c, $ops) = $lei->workers_start($self, 1); $lei->{wq1} = $self; $self->wq_io_do('do_ls_search_long', [], $pfx); $self->wq_close(1); - $op_c->op_wait_event($ops); + $lei->wait_wq_events($op_c, $ops); } sub lei_ls_search { diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index a37e1d5c626cdfe35398b354a22a686a48e8e679..39671f902b5514b19657bb7e937a06c935aca76d 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -282,11 +282,11 @@ require PublicInbox::Lock; require PublicInbox::Inbox; require PublicInbox::Admin; require PublicInbox::InboxWritable; - my ($op, $ops) = $lei->workers_start($self, 1); + my ($op_c, $ops) = $lei->workers_start($self, 1); $lei->{wq1} = $self; $self->wq_io_do('do_mirror', []); $self->wq_close(1); - $op->op_wait_event($ops); + $lei->wait_wq_events($op_c, $ops); } sub ipc_atfork_child { diff --git a/lib/PublicInbox/LeiP2q.pm b/lib/PublicInbox/LeiP2q.pm index f381a31c543be181b18f4b595e6a0201758c0aaa..c0c4563d6fbb86a1638bf1917bf83f41d9a5525b 100644 --- a/lib/PublicInbox/LeiP2q.pm +++ b/lib/PublicInbox/LeiP2q.pm @@ -188,11 +188,11 @@ $self->{0} = delete $lei->{0}; # guard from _lei_atfork_child } else { $self->{input} = $input; } - my ($op, $ops) = $lei->workers_start($self, 1); + my ($op_c, $ops) = $lei->workers_start($self, 1); $lei->{wq1} = $self; $self->wq_io_do('do_p2q', []); $self->wq_close(1); - $op->op_wait_event($ops); + $lei->wait_wq_events($op_c, $ops); } sub ipc_atfork_child { diff --git a/lib/PublicInbox/LeiRediff.pm b/lib/PublicInbox/LeiRediff.pm index c8bd0dfbe19ead99c9673ab91ad154f0a5504590..7607b44f5aece34d5db15989f78904935096b210 100644 --- a/lib/PublicInbox/LeiRediff.pm +++ b/lib/PublicInbox/LeiRediff.pm @@ -227,7 +227,7 @@ $lei->start_pager if $isatty; my ($op_c, $ops) = $lei->workers_start($self, 1); $lei->{wq1} = $self; net_merge_all_done($self) unless $lei->{auth}; - $op_c->op_wait_event($ops); + $lei->wait_wq_events($op_c, $ops); } sub ipc_atfork_child { diff --git a/lib/PublicInbox/LeiRm.pm b/lib/PublicInbox/LeiRm.pm index c6d280452f12c70bed10a3e694bc63fe6f8c16ae..578e9811495080f2d620bcb52e0900db2331152c 100644 --- a/lib/PublicInbox/LeiRm.pm +++ b/lib/PublicInbox/LeiRm.pm @@ -38,7 +38,7 @@ my ($op_c, $ops) = $lei->workers_start($self, 1); $lei->{wq1} = $self; $lei->{-err_type} = 'non-fatal'; net_merge_all_done($self) unless $lei->{auth}; - $op_c->op_wait_event($ops); + $lei->wait_wq_events($op_c, $ops); } no warnings 'once'; diff --git a/lib/PublicInbox/LeiTag.pm b/lib/PublicInbox/LeiTag.pm index b6abd53367f7cfe5c2c24d96b7f60d487d2399cb..4b3ce7d87061c717c2647e2995debc55f76441ee 100644 --- a/lib/PublicInbox/LeiTag.pm +++ b/lib/PublicInbox/LeiTag.pm @@ -53,7 +53,7 @@ (my $op_c, $ops) = $lei->workers_start($self, $j, $ops); $lei->{wq1} = $self; $lei->{-err_type} = 'non-fatal'; net_merge_all_done($self) unless $lei->{auth}; - $op_c->op_wait_event($ops); + $lei->wait_wq_events($op_c, $ops); } sub note_missing { diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index 75e55d476710f2df4c8e933f4445728bda252424..beb955bb6de599a5ce675276888f17f6f0c83495 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -532,7 +532,7 @@ } else { start_query($self); } $lei->event_step_init; # wait for shutdowns - $op_c->op_wait_event($ops); + $lei->wait_wq_events($op_c, $ops); } sub add_uri { diff --git a/lib/PublicInbox/PktOp.pm b/lib/PublicInbox/PktOp.pm index ca098d3cb53993734dc7398843022bc032e9a9a1..92e150a46bdf2126ad7bcf13e52de2b1ca4794ae 100644 --- a/lib/PublicInbox/PktOp.pm +++ b/lib/PublicInbox/PktOp.pm @@ -63,10 +63,4 @@ return $self->close if $msg eq ''; # close on EOF } } -# call this when we're ready to wait on events -sub op_wait_event { - my ($self, $ops) = @_; - $self->{ops} = $ops; -} - 1;