From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5CE3B1FB07 for ; Thu, 21 Jan 2021 19:46:25 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 09/12] lei_xsearch: reduce reference paths to lxs Date: Thu, 21 Jan 2021 19:46:21 +0000 Message-Id: <20210121194624.32002-10-e@80x24.org> In-Reply-To: <20210121194624.32002-1-e@80x24.org> References: <20210121194624.32002-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Having an extra reference to LeiXSearch from the OpPipe $done_op map is unnecessary and makes the reference graph more complex than it needs to be. Just use $lei->{lxs} to simplify and reduce the likelyhood of bugs. --- lib/PublicInbox/LeiXSearch.pm | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index 7b33677e..987a9896 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -192,12 +192,14 @@ sub git { } sub query_done { # EOF callback - my ($self, $lei) = @_; - my $l2m = delete $lei->{l2m}; - $l2m->wq_wait_old if $l2m; - $self->wq_wait_old; + my ($lei) = @_; + my $has_l2m = exists $lei->{l2m}; + for my $f (qw(lxs l2m)) { + my $wq = delete $lei->{$f} or next; + $wq->wq_wait_old; + } $lei->{ovv}->ovv_end($lei); - if ($l2m) { # close() calls LeiToMail reap_compress + if ($has_l2m) { # close() calls LeiToMail reap_compress close(delete($lei->{1})) if $lei->{1}; $lei->start_mua; } @@ -246,16 +248,14 @@ sub query_prepare { # called by wq_do syswrite($lei->{0}, '.') == 1 or die "do_post_augment trigger: $!"; } -sub sigpipe_handler { # handles SIGPIPE from wq workers - my ($self, $lei_orig) = @_; - if ($self->wq_kill_old) { +sub sigpipe_handler { # handles SIGPIPE from l2m/lxs workers + my ($lei) = @_; + my $lxs = delete $lei->{lxs}; + if ($lxs && $lxs->wq_kill_old) { kill 'PIPE', $$; - $self->wq_wait_old; - } else { - $self->wq_kill; - $self->wq_close; + $lxs->wq_wait_old; } - close(delete $lei_orig->{1}) if $lei_orig->{1}; + close(delete $lei->{1}) if $lei->{1}; } sub do_query { @@ -266,8 +266,8 @@ sub do_query { $lei_orig->event_step_init; # wait for shutdowns my $done_op = { - '' => [ \&query_done, $self, $lei_orig ], - '!' => [ \&sigpipe_handler, $self, $lei_orig ] + '' => [ \&query_done, $lei_orig ], + '!' => [ \&sigpipe_handler, $lei_orig ] }; my $in_loop = exists $lei_orig->{sock}; $done = PublicInbox::OpPipe->new($done, $done_op, $in_loop);