about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiQuery.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-01-13 19:06:15 -1200
committerEric Wong <e@80x24.org>2021-01-14 23:14:08 +0000
commit39d44555e3f04c97e98c7f5d3538bbba6a19656b (patch)
tree034da2d3634118b076b95e126f73f875795ddb3a /lib/PublicInbox/LeiQuery.pm
parent7dd5b28cb9bdcfa262ddad47d7f033f600675dc3 (diff)
downloadpublic-inbox-39d44555e3f04c97e98c7f5d3538bbba6a19656b.tar.gz
The new test ensures consistency between oneshot and
client/daemon users.  Cancelling an in-progress result now also
stops xsearch workers to avoid wasted CPU and I/O.

Note the lei->atfork_child_wq usage changes, it is to workaround
a bug in Perl 5: http://nntp.perl.org/group/perl.perl5.porters/258784
<CAHhgV8hPbcmkzWizp6Vijw921M5BOXixj4+zTh3nRS9vRBYk8w@mail.gmail.com>

This switches the internal protocol to use SOCK_SEQPACKET
AF_UNIX sockets to prevent merging messages from the daemon to
client to run pager and kill/exit the client script.
Diffstat (limited to 'lib/PublicInbox/LeiQuery.pm')
-rw-r--r--lib/PublicInbox/LeiQuery.pm22
1 files changed, 6 insertions, 16 deletions
diff --git a/lib/PublicInbox/LeiQuery.pm b/lib/PublicInbox/LeiQuery.pm
index 7ca01454..1a3e1193 100644
--- a/lib/PublicInbox/LeiQuery.pm
+++ b/lib/PublicInbox/LeiQuery.pm
@@ -40,14 +40,13 @@ sub lei_q {
         if ($opt->{external} // 1) {
                 $self->_externals_each(\&_vivify_external, \@srcs);
         }
-        my $j = $opt->{jobs} // scalar(@srcs) > 3 ? 3 : scalar(@srcs);
+        my $j = $opt->{jobs} // (scalar(@srcs) > 3 ? 3 : scalar(@srcs));
         $j = 1 if !$opt->{thread};
         $j++ if $opt->{'local'}; # for sto->search below
-        if ($self->{sock}) {
-                $self->atfork_prepare_wq($lxs);
-                $lxs->wq_workers_start('lei_xsearch', $j, $self->oldset)
-                        // $lxs->wq_workers($j);
-        }
+        $self->atfork_prepare_wq($lxs);
+        $lxs->wq_workers_start('lei_xsearch', $j, $self->oldset)
+                // $lxs->wq_workers($j);
+
         unshift(@srcs, $sto->search) if $opt->{'local'};
         # no forking workers after this
         require PublicInbox::LeiOverview;
@@ -77,16 +76,7 @@ sub lei_q {
         # my $wcb = PublicInbox::LeiToMail->write_cb($out, $self);
         $self->{mset_opt} = \%mset_opt;
         $self->{ovv}->ovv_begin($self);
-        pipe(my ($eof_wait, $qry_done)) or die "pipe $!";
-        require PublicInbox::EOFpipe;
-        my $eof = PublicInbox::EOFpipe->new($eof_wait, \&query_done, $self);
-        $lxs->do_query($self, $qry_done, \@srcs);
-        $eof->event_step unless $self->{sock};
-}
-
-sub query_done { # PublicInbox::EOFpipe callback
-        my ($self) = @_;
-        $self->{ovv}->ovv_end($self);
+        $lxs->do_query($self, \@srcs);
 }
 
 1;