]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiXSearch.pm
lib: explicitly distinguish oneshot use
[public-inbox.git] / lib / PublicInbox / LeiXSearch.pm
index 95862306cd7a98beba3aca94659f17bd7bf3460a..e997431f1e5521f657cbf284b97f48e6e5199845 100644 (file)
@@ -268,6 +268,7 @@ sub query_remote_mboxrd {
                my $e = do { local $/; <$cerr> } //
                                die "read(curl stderr): $!\n";
                $coff += length($e);
+               truncate($cerr, 0);
                next if (($? >> 8) == 22 && $e =~ /\b404\b/);
                $lei->child_error($?);
                $uri->query_form(q => $lei->{mset_opt}->{qstr});
@@ -408,7 +409,6 @@ sub do_query {
                fcntl($lei->{startq}, 1031, 4096) if $^O eq 'linux';
                $zpipe = $l2m->pre_augment($lei);
        }
-       my $in_loop = exists $lei->{sock};
        my $ops = {
                '|' => [ \&sigpipe_handler, $lei ],
                '!' => [ \&fail_handler, $lei ],
@@ -416,7 +416,7 @@ sub do_query {
                '' => [ \&query_done, $lei ],
                'mset_progress' => [ \&mset_progress, $lei ],
        };
-       (my $op, $lei->{pkt_op}) = PublicInbox::PktOp->pair($ops, $in_loop);
+       (my $op, $lei->{pkt_op}) = PublicInbox::PktOp->pair($ops, !$lei->{oneshot});
        my ($lei_ipc, @io) = $lei->atfork_parent_wq($self);
        delete($lei->{pkt_op});
 
@@ -427,7 +427,7 @@ sub do_query {
        }
        start_query($self, \@io, $lei_ipc);
        $self->wq_close(1);
-       unless ($in_loop) {
+       if ($lei->{oneshot}) {
                # for the $lei_ipc->atfork_child_wq PIPE handler:
                while ($op->{sock}) { $op->event_step }
        }