From 757652fd1ad6843c984610263a2a0b336c974111 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 7 Feb 2021 08:51:53 +0000 Subject: ipc: wq_do => wq_io_do We will have a ->wq_do that doesn't pass FDs for I/O. --- lib/PublicInbox/IPC.pm | 12 ++++++------ lib/PublicInbox/LeiImport.pm | 4 ++-- lib/PublicInbox/LeiMirror.pm | 4 ++-- lib/PublicInbox/LeiOverview.pm | 4 ++-- lib/PublicInbox/LeiToMail.pm | 2 +- lib/PublicInbox/LeiXSearch.pm | 10 +++++----- 6 files changed, 18 insertions(+), 18 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/IPC.pm b/lib/PublicInbox/IPC.pm index 7e5a0b16..728f726c 100644 --- a/lib/PublicInbox/IPC.pm +++ b/lib/PublicInbox/IPC.pm @@ -3,10 +3,10 @@ # base class for remote IPC calls and workqueues, requires Storable or Sereal # - ipc_do and ipc_worker_* is for a single worker/producer and uses pipes -# - wq_do and wq_worker* is for a single producer and multiple workers, +# - wq_io_do and wq_worker* is for a single producer and multiple workers, # using SOCK_SEQPACKET for work distribution # use ipc_do when you need work done on a certain process -# use wq_do when your work can be done on any idle worker +# use wq_io_do when your work can be done on any idle worker package PublicInbox::IPC; use strict; use v5.10.1; @@ -248,12 +248,12 @@ sub wq_worker_loop ($) { PublicInbox::DS->Reset; } -sub do_sock_stream { # via wq_do, for big requests +sub do_sock_stream { # via wq_io_do, for big requests my ($self, $len) = @_; recv_and_run($self, delete $self->{0}, $len, 1); } -sub wq_do { # always async +sub wq_io_do { # always async my ($self, $sub, $ios, @args) = @_; if (my $s1 = $self->{-wq_s1}) { # run in worker my $fds = [ map { fileno($_) } @$ios ]; @@ -278,7 +278,7 @@ sub wq_do { # always async } else { @$self{0..$#$ios} = @$ios; eval { $self->$sub(@args) }; - warn "wq_do: $@" if $@; + warn "wq_io_do: $@" if $@; delete @$self{0..$#$ios}; # don't close } } @@ -349,7 +349,7 @@ sub wq_worker_decr { # SIGTTOU handler, kills first idle worker my ($self) = @_; return unless wq_workers($self); my $s2 = $self->{-wq_s2} // die 'BUG: no wq_s2'; - $self->wq_do('wq_exit', [ $s2, $s2, $s2 ]); + $self->wq_io_do('wq_exit', [ $s2, $s2, $s2 ]); # caller must call wq_worker_decr_wait in main loop } diff --git a/lib/PublicInbox/LeiImport.pm b/lib/PublicInbox/LeiImport.pm index 2c7cbf2b..3a99570e 100644 --- a/lib/PublicInbox/LeiImport.pm +++ b/lib/PublicInbox/LeiImport.pm @@ -44,9 +44,9 @@ sub call { # the main "lei import" method $self->wq_workers_start('lei_import', $j, $lei->oldset, {lei => $lei}); my $op = delete $lei->{pkt_op_c}; delete $lei->{pkt_op_p}; - $self->wq_do('import_stdin', []) if $self->{0}; + $self->wq_io_do('import_stdin', []) if $self->{0}; for my $x (@argv) { - $self->wq_do('import_path_url', [], $x); + $self->wq_io_do('import_path_url', [], $x); } $self->wq_close(1); $lei->event_step_init; # wait for shutdowns diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index 13795a58..5ba69287 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -251,7 +251,7 @@ sub start_clone_url { die "TODO: non-HTTP/HTTPS clone of $self->{src} not supported, yet"; } -sub do_mirror { # via wq_do +sub do_mirror { # via wq_io_do my ($self) = @_; my $lei = $self->{lei}; eval { @@ -290,7 +290,7 @@ sub start { $self->wq_workers_start('lei_mirror', 1, $lei->oldset, {lei => $lei}); my $op = delete $lei->{pkt_op_c}; delete $lei->{pkt_op_p}; - $self->wq_do('do_mirror', []); + $self->wq_io_do('do_mirror', []); $self->wq_close(1); $lei->event_step_init; # wait for shutdowns if ($lei->{oneshot}) { diff --git a/lib/PublicInbox/LeiOverview.pm b/lib/PublicInbox/LeiOverview.pm index 24e4c190..dcfb9cc7 100644 --- a/lib/PublicInbox/LeiOverview.pm +++ b/lib/PublicInbox/LeiOverview.pm @@ -23,7 +23,7 @@ my $JSONL = 'ldjson|ndjson|jsonl'; # 3 names for the same thing sub _iso8601 ($) { strftime('%Y-%m-%dT%H:%M:%SZ', gmtime($_[0])) } -# we open this in the parent process before ->wq_do handoff +# we open this in the parent process before ->wq_io_do handoff sub ovv_out_lk_init ($) { my ($self) = @_; my $tmp = File::Temp->new("lei-ovv.dst.$$.lock-XXXXXX", @@ -205,7 +205,7 @@ sub ovv_each_smsg_cb { # runs in wq worker usually sub { my ($smsg, $mitem) = @_; $smsg->{pct} = get_pct($mitem) if $mitem; - $l2m->wq_do('write_mail', [], $git_dir, $smsg); + $l2m->wq_io_do('write_mail', [], $git_dir, $smsg); } } elsif ($self->{fmt} =~ /\A(concat)?json\z/ && $lei->{opt}->{pretty}) { my $EOR = ($1//'') eq 'concat' ? "\n}" : "\n},"; diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm index 4f847221..3f65e9e9 100644 --- a/lib/PublicInbox/LeiToMail.pm +++ b/lib/PublicInbox/LeiToMail.pm @@ -488,7 +488,7 @@ sub poke_dst { } } -sub write_mail { # via ->wq_do +sub write_mail { # via ->wq_io_do my ($self, $git_dir, $smsg) = @_; my $git = $self->{"$$\0$git_dir"} //= PublicInbox::Git->new($git_dir); git_async_cat($git, $smsg->{blob}, \&git_to_mail, diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index 6a1b107b..1ba767c1 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -333,10 +333,10 @@ sub start_query { # always runs in main (lei-daemon) process } if ($lei->{opt}->{thread}) { for my $ibxish (locals($self)) { - $self->wq_do('query_thread_mset', [], $ibxish); + $self->wq_io_do('query_thread_mset', [], $ibxish); } } elsif (locals($self)) { - $self->wq_do('query_mset', []); + $self->wq_io_do('query_mset', []); } my $i = 0; my $q = []; @@ -344,7 +344,7 @@ sub start_query { # always runs in main (lei-daemon) process push @{$q->[$i++ % $MAX_PER_HOST]}, $uri; } for my $uris (@$q) { - $self->wq_do('query_remote_mboxrd', [], $uris); + $self->wq_io_do('query_remote_mboxrd', [], $uris); } } @@ -354,7 +354,7 @@ sub ipc_atfork_child { $self->SUPER::ipc_atfork_child; } -sub query_prepare { # called by wq_do +sub query_prepare { # called by wq_io_do my ($self) = @_; local $0 = "$0 query_prepare"; my $lei = $self->{lei}; @@ -398,7 +398,7 @@ sub do_query { delete $lei->{pkt_op_p}; $l2m->wq_close(1) if $l2m; $lei->event_step_init; # wait for shutdowns - $self->wq_do('query_prepare', []) if $l2m; + $self->wq_io_do('query_prepare', []) if $l2m; start_query($self, $lei); $self->wq_close(1); # lei_xsearch workers stop when done if ($lei->{oneshot}) { -- cgit v1.2.3-24-ge0c7