]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiXSearch.pm
lei_xsearch: load PublicInbox::Smsg
[public-inbox.git] / lib / PublicInbox / LeiXSearch.pm
index e69b637c7a29d1ef0da2e4c86780c5d4ba112c21..4d390ee4661444d403ad3f45fdcbb7b32868a3fb 100644 (file)
@@ -16,6 +16,7 @@ use File::Spec ();
 use PublicInbox::Search qw(xap_terms);
 use PublicInbox::Spawn qw(popen_rd spawn which);
 use PublicInbox::MID qw(mids);
+use PublicInbox::Smsg;
 use Fcntl qw(SEEK_SET F_SETFL O_APPEND O_RDWR);
 
 sub new {
@@ -109,8 +110,7 @@ sub wait_startq ($) {
 sub query_thread_mset { # for --thread
        my ($self, $lei, $ibxish) = @_;
        local $0 = "$0 query_thread_mset";
-       my %sig = $lei->atfork_child_wq($self);
-       local @SIG{keys %sig} = values %sig;
+       $lei->atfork_child_wq($self);
        my $startq = delete $lei->{startq};
 
        my ($srch, $over) = ($ibxish->search, $ibxish->over);
@@ -145,8 +145,7 @@ sub query_thread_mset { # for --thread
 sub query_mset { # non-parallel for non-"--thread" users
        my ($self, $lei) = @_;
        local $0 = "$0 query_mset";
-       my %sig = $lei->atfork_child_wq($self);
-       local @SIG{keys %sig} = values %sig;
+       $lei->atfork_child_wq($self);
        my $startq = delete $lei->{startq};
        my $mo = { %{$lei->{mset_opt}} };
        my $mset;
@@ -187,8 +186,7 @@ sub kill_reap {
 sub query_remote_mboxrd {
        my ($self, $lei, $uris) = @_;
        local $0 = "$0 query_remote_mboxrd";
-       my %sig = $lei->atfork_child_wq($self); # keep $self->{5} startq
-       local @SIG{keys %sig} = values %sig;
+       $lei->atfork_child_wq($self);
        my ($opt, $env) = @$lei{qw(opt env)};
        my @qform = (q => $lei->{mset_opt}->{qstr}, x => 'm');
        push(@qform, t => 1) if $opt->{thread};
@@ -286,7 +284,7 @@ sub query_done { # EOF callback
        my $has_l2m = exists $lei->{l2m};
        for my $f (qw(lxs l2m)) {
                my $wq = delete $lei->{$f} or next;
-               $wq->wq_wait_old;
+               $wq->wq_wait_old($lei);
        }
        $lei->{ovv}->ovv_end($lei);
        if ($has_l2m) { # close() calls LeiToMail reap_compress
@@ -351,9 +349,7 @@ sub start_query { # always runs in main (lei-daemon) process
 sub query_prepare { # called by wq_do
        my ($self, $lei) = @_;
        local $0 = "$0 query_prepare";
-       my %sig = $lei->atfork_child_wq($self);
-       -p $lei->{op_pipe} or die "BUG: \$done pipe expected";
-       local @SIG{keys %sig} = values %sig;
+       $lei->atfork_child_wq($self);
        delete $lei->{l2m}->{-wq_s1};
        eval { $lei->{l2m}->do_augment($lei) };
        $lei->fail($@) if $@;
@@ -363,11 +359,11 @@ sub query_prepare { # called by wq_do
 sub sigpipe_handler { # handles SIGPIPE from l2m/lxs workers
        my ($lei) = @_;
        my $lxs = delete $lei->{lxs};
-       if ($lxs && $lxs->wq_kill_old) {
-               kill 'PIPE', $$;
-               $lxs->wq_wait_old;
+       if ($lxs && $lxs->wq_kill_old) { # is this the daemon?
+               $lxs->wq_wait_old($lei);
        }
        close(delete $lei->{1}) if $lei->{1};
+       $lei->x_it(13);
 }
 
 sub do_query {