about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-01-21 19:46:21 +0000
committerEric Wong <e@80x24.org>2021-01-22 16:18:01 -0400
commitd3f54eb1ac998c79c55f10fbfb5bce389041a0fe (patch)
tree671c25ed5aaf0d3426badee1687aa9a235c00006
parent3e11b08275331783f4860a590b1555b879c77328 (diff)
downloadpublic-inbox-d3f54eb1ac998c79c55f10fbfb5bce389041a0fe.tar.gz
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.
-rw-r--r--lib/PublicInbox/LeiXSearch.pm30
1 files 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);