Redundant code is noise and therefore confusing :< --- lib/PublicInbox/LeiImportKw.pm | 8 +------- lib/PublicInbox/LeiMirror.pm | 10 ++-------- lib/PublicInbox/LeiNoteEvent.pm | 8 +------- lib/PublicInbox/LeiPmdir.pm | 8 +------- script/public-inbox-clone | 2 +- 5 files changed, 6 insertions(+), 30 deletions(-)
diff --git a/lib/PublicInbox/LeiImportKw.pm b/lib/PublicInbox/LeiImportKw.pm index 21c93515..c35c5c26 100644 --- a/lib/PublicInbox/LeiImportKw.pm +++ b/lib/PublicInbox/LeiImportKw.pm @@ -46,17 +46,11 @@ sub ck_update_kw { # via wq_io_do $self->{sto}->wq_do('set_eml_vmd', undef, { kw => $kw }, \@docids); } -sub ikw_done_wait { - my ($arg, $pid) = @_; - my ($self, $lei) = @$arg; - $lei->can('wq_done_wait')->($arg, $pid); -} - sub _lei_wq_eof { # EOF callback for main lei daemon my ($lei) = @_; my $ikw = delete $lei->{ikw} or return $lei->fail; $lei->sto_done_request($ikw->{lei_sock}); - $ikw->wq_wait_old(\&ikw_done_wait, $lei); + $ikw->wq_wait_old($lei->can('wq_done_wait'), $lei); } 1; diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index d9c13f05..6bfa4b6f 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -11,7 +11,7 @@ use PublicInbox::Spawn qw(popen_rd spawn run_die); use File::Temp (); use Fcntl qw(SEEK_SET O_CREAT O_EXCL O_WRONLY); -sub do_finish_mirror { # dwaitpid callback +sub _wq_done_wait { # dwaitpid callback (via wq_eof) my ($arg, $pid) = @_; my ($mrr, $lei) = @$arg; my $f = "$mrr->{dst}/mirror.done"; @@ -28,12 +28,6 @@ sub do_finish_mirror { # dwaitpid callback $lei->dclose; } -sub _lei_wq_eof { # EOF callback for main daemon - my ($lei) = @_; - my $mrr = delete $lei->{wq1} or return $lei->fail; - $mrr->wq_wait_old(\&do_finish_mirror, $lei); -} - # for old installations without manifest.js.gz sub try_scrape { my ($self) = @_; @@ -176,7 +170,7 @@ sub index_cloned_inbox { PublicInbox::Admin::progress_prepare($opt, $lei->{2}); PublicInbox::Admin::index_inbox($ibx, undef, $opt); } - open my $x, '>', "$self->{dst}/mirror.done"; # for do_finish_mirror + open my $x, '>', "$self->{dst}/mirror.done"; # for _wq_done_wait } sub run_reap { diff --git a/lib/PublicInbox/LeiNoteEvent.pm b/lib/PublicInbox/LeiNoteEvent.pm index 43d5ed0f..d2429485 100644 --- a/lib/PublicInbox/LeiNoteEvent.pm +++ b/lib/PublicInbox/LeiNoteEvent.pm @@ -107,17 +107,11 @@ sub ipc_atfork_child { $self->SUPER::ipc_atfork_child; } -sub lne_done_wait { - my ($arg, $pid) = @_; - my ($self, $lei) = @$arg; - $lei->can('wq_done_wait')->($arg, $pid); -} - sub _lei_wq_eof { # EOF callback for main lei daemon my ($lei) = @_; my $lne = delete $lei->{lne} or return $lei->fail; $lei->sto_done_request; - $lne->wq_wait_old(\&lne_done_wait, $lei); + $lne->wq_wait_old($lei->can('wq_done_wait'), $lei); } 1; diff --git a/lib/PublicInbox/LeiPmdir.pm b/lib/PublicInbox/LeiPmdir.pm index 23bccb4f..2d3b9755 100644 --- a/lib/PublicInbox/LeiPmdir.pm +++ b/lib/PublicInbox/LeiPmdir.pm @@ -47,17 +47,11 @@ sub mdir_iter { # via wq_io_do $self->{ipt}->pmdir_cb($f, $fl, @args); } -sub pmd_done_wait { - my ($arg, $pid) = @_; - my ($self, $lei) = @$arg; - $lei->can('wq_done_wait')->($arg, $pid); -} - sub _lei_wq_eof { # EOF callback for main lei daemon my ($lei) = @_; my $pmd = delete $lei->{pmd} or return $lei->fail; $lei->sto_done_request($pmd->{lei_sock}); - $pmd->wq_wait_old(\&pmd_done_wait, $lei); + $pmd->wq_wait_old($lei->can('wq_done_wait'), $lei); } 1; diff --git a/script/public-inbox-clone b/script/public-inbox-clone index 2b18969f..0efde1a8 100755 --- a/script/public-inbox-clone +++ b/script/public-inbox-clone @@ -54,5 +54,5 @@ my $mrr = bless { dst => $dst, }, 'PublicInbox::LeiMirror'; $mrr->do_mirror; -$mrr->can('do_finish_mirror')->([$mrr, $lei], $$); +$mrr->can('_wq_done_wait')->([$mrr, $lei], $$); exit(($lei->{child_error} // 0) >> 8); -- unsubscribe: one-click, see List-Unsubscribe header archive: https://public-inbox.org/meta/