diff options
author | Eric Wong <e@80x24.org> | 2023-01-17 07:19:10 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-01-18 23:26:03 +0000 |
commit | 4a2a95bbc78f99c8c5278cfe29de74bd1483903c (patch) | |
tree | 8652affab199e745cb52da49f526a2d998e755fb /lib/PublicInbox/LeiXSearch.pm | |
parent | f7f0e7bee09cfc57ecc6845a8cf9e80a0bbd64f5 (diff) | |
download | public-inbox-4a2a95bbc78f99c8c5278cfe29de74bd1483903c.tar.gz |
This avoids awkwardly stuffing an arrayref into callbacks which expect multiple arguments. IPC->awaitpid_init now allows pre-registering callbacks before spawning workers.
Diffstat (limited to 'lib/PublicInbox/LeiXSearch.pm')
-rw-r--r-- | lib/PublicInbox/LeiXSearch.pm | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index 730df1f7..f9aa870e 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -400,9 +400,8 @@ sub query_remote_mboxrd { sub git { $_[0]->{git} // die 'BUG: git uninitialized' } -sub xsearch_done_wait { # dwaitpid callback - my ($arg, $pid) = @_; - my ($wq, $lei) = @$arg; +sub xsearch_done_wait { # awaitpid cb (via awaitpid_init) + my ($pid, $wq, $lei) = @_; return if !$?; my $s = $? & 127; return $lei->child_error($?) if $s == 13 || $s == 15; @@ -573,16 +572,16 @@ sub do_query { fcntl($b_r, $F_SETPIPE_SZ, 4096) if $F_SETPIPE_SZ; $l2m->{au_peers} = [ $a_r, $a_w, $b_r, $b_w ]; } + $l2m->awaitpid_init(\&xsearch_done_wait, $lei); $l2m->wq_workers_start('lei2mail', undef, $lei->oldset, { lei => $lei }); - $l2m->wq_wait_async(\&xsearch_done_wait, $lei); pipe($lei->{startq}, $lei->{au_done}) or die "pipe: $!"; fcntl($lei->{startq}, $F_SETPIPE_SZ, 4096) if $F_SETPIPE_SZ; delete $l2m->{au_peers}; } + $self->awaitpid_init(\&xsearch_done_wait, $lei); $self->wq_workers_start('lei_xsearch', undef, $lei->oldset, { lei => $lei }); - $self->wq_wait_async(\&xsearch_done_wait, $lei); my $op_c = delete $lei->{pkt_op_c}; delete $lei->{pkt_op_p}; @$end = (); |