]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LEI.pm
ds: block signals when reaping
[public-inbox.git] / lib / PublicInbox / LEI.pm
index 9c3308ad143e98085505507c066ac1c528a7bdcc..12e227d2ace7d183161235d9a77d8027ffb2dee8 100644 (file)
@@ -8,7 +8,8 @@
 package PublicInbox::LEI;
 use strict;
 use v5.10.1;
-use parent qw(PublicInbox::DS PublicInbox::LeiExternal);
+use parent qw(PublicInbox::DS PublicInbox::LeiExternal
+       PublicInbox::LeiQuery);
 use Getopt::Long ();
 use Socket qw(AF_UNIX SOCK_STREAM pack_sockaddr_un);
 use Errno qw(EAGAIN ECONNREFUSED ENOENT);
@@ -80,7 +81,7 @@ sub _config_path ($) {
 our %CMD = ( # sorted in order of importance/use:
 'q' => [ 'SEARCH_TERMS...', 'search for messages matching terms', qw(
        save-as=s output|mfolder|o=s format|f=s dedupe|d=s thread|t augment|a
-       sort|s=s@ reverse|r offset=i remote local! external!
+       sort|s=s reverse|r offset=i remote local! external! pretty
        since|after=s until|before=s), opt_dash('limit|n=i', '[0-9]+') ],
 
 'show' => [ 'MID|OID', 'show a given object (Message-ID or object ID)',
@@ -202,8 +203,9 @@ my %OPTDESC = (
 'limit|n=i@' => ['NUM', 'limit on number of matches (default: 10000)' ],
 'offset=i' => ['OFF', 'search result offset (default: 0)'],
 
-'sort|s=s@' => [ 'VAL|internaldate,date,relevance,docid',
+'sort|s=s' => [ 'VAL|received,relevance,docid',
                "order of results `--output'-dependent"],
+'reverse|r' => [ 'reverse search results' ], # like sort(1)
 
 'boost=i' => 'increase/decrease priority of results (default: 0)',
 
@@ -469,10 +471,6 @@ sub lei_show {
        my ($self, @argv) = @_;
 }
 
-sub lei_query {
-       my ($self, @argv) = @_;
-}
-
 sub lei_mark {
        my ($self, @argv) = @_;
 }
@@ -609,7 +607,8 @@ sub start_pager {
        my $rdr = { 0 => $r, 1 => $self->{1}, 2 => $self->{2} };
        $self->{1} = $w;
        $self->{2} = $w if -t $self->{2};
-       $self->{'pager.pid'} = spawn([$pager], $env, $rdr);
+       my $pid = spawn([$pager], $env, $rdr);
+       dwaitpid($pid, undef, $self->{sock});
        $env->{GIT_PAGER_IN_USE} = 'true'; # we may spawn git
 }
 
@@ -691,7 +690,7 @@ sub lazy_start {
        my @st = stat($path) or die "stat($path): $!";
        my $dev_ino_expect = pack('dd', $st[0], $st[1]); # dev+ino
        pipe(my ($eof_r, $eof_w)) or die "pipe: $!";
-       my $oldset = PublicInbox::Sigfd::block_signals();
+       my $oldset = PublicInbox::DS::block_signals();
        if ($nfd == 1) {
                require IO::FDPass;
                $recv_3fds = sub { map { IO::FDPass::recv($_[0]) } (0..2) };
@@ -738,7 +737,7 @@ sub lazy_start {
        } else {
                # wake up every second to accept signals if we don't
                # have signalfd or IO::KQueue:
-               PublicInbox::Sigfd::sig_setmask($oldset);
+               PublicInbox::DS::sig_setmask($oldset);
                PublicInbox::DS->SetLoopTimeout(1000);
        }
        PublicInbox::DS->SetPostLoopCallback(sub {
@@ -803,9 +802,6 @@ sub oneshot {
 sub DESTROY {
        my ($self) = @_;
        $self->{1}->autoflush(1);
-       if (my $pid = delete $self->{'pager.pid'}) {
-               dwaitpid($pid, undef, $self->{sock});
-       }
 }
 
 1;