X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FLEI.pm;h=d81ca296250b493f4e05e1c00bcd2b7bb74781c3;hb=ec8af85ec73346e243624b2ddad2d3723fde704d;hp=887025de5dedb608576b2263b4f20c0596fce8e5;hpb=0054246c2d03fcc91bc899da5ef41a68f505e542;p=public-inbox.git diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 887025de..d81ca296 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2020-2021 all contributors +# Copyright (C) all contributors # License: AGPL-3.0+ # Backend for `lei' (local email interface). Unlike the C10K-oriented @@ -6,8 +6,7 @@ # local clients with read/write access to the FS and use as many # system resources as the local user has access to. package PublicInbox::LEI; -use strict; -use v5.10.1; +use v5.12; use parent qw(PublicInbox::DS PublicInbox::LeiExternal PublicInbox::LeiQuery); use Getopt::Long (); @@ -411,6 +410,9 @@ my %OPTDESC = ( 'url ls-mail-source' => 'show full URL of newsgroup or IMAP folder', 'format|f=s ls-external' => $ls_format, +'prune:s forget-search' => + ['TYPE|local|remote', 'prune all, remote or local folders' ], + 'limit|n=i@' => ['NUM', 'limit on number of matches (default: 10000)' ], 'offset=i' => ['OFF', 'search result offset (default: 0)'], @@ -657,6 +659,7 @@ sub wait_wq_events { for my $wq (grep(defined, @$lei{qw(ikw pmd)})) { # auxiliary WQs $wq->wq_close; } + $wq1->{lei_sock} = $lei->{sock} if $wq1; $op_c->{ops} = $ops; } @@ -815,7 +818,8 @@ sub dispatch { next if $d eq ''; # same as git(1) chdir $d or return fail($self, "cd $d: $!"); } - open $self->{3}, '.' or return fail($self, "open . $!"); + open $self->{3}, '<', '.' or + return fail($self, "open . $!"); } $cb->($self, @argv); } elsif (grep(/\A-/, $cmd, @argv)) { # --help or -h only @@ -1145,6 +1149,7 @@ sub event_step { if (scalar(@fds) == 1 && !defined($fds[0])) { return if $! == EAGAIN; die "recvmsg: $!" if $! != ECONNRESET; + $buf = ''; @fds = (); # for open loop below: } for (@fds) { open my $rfh, '+<&=', $_ } @@ -1272,6 +1277,9 @@ sub lazy_start { require PublicInbox::CmdIPC4; $send_cmd = PublicInbox::CmdIPC4->can('send_cmd4'); PublicInbox::CmdIPC4->can('recv_cmd4'); + } // do { + $send_cmd = PublicInbox::Syscall->can('send_cmd4'); + PublicInbox::Syscall->can('recv_cmd4'); }; } $recv_cmd or die <<""; @@ -1386,7 +1394,7 @@ sub wq_done_wait { # dwaitpid callback local $current_lei = $lei; my $err_type = $lei->{-err_type}; $? and $lei->child_error($?, - $err_type ? "$err_type errors during $lei->{cmd}" : ()); + $err_type ? "$err_type errors during $lei->{cmd} \$?=$?" : ()); $lei->dclose; } @@ -1397,9 +1405,11 @@ sub fchdir { } sub wq_eof { # EOF callback for main daemon - my ($lei) = @_; + my ($lei, $wq_fld) = @_; local $current_lei = $lei; - delete $lei->{wq1} // return $lei->fail; # already failed + my $wq = delete $lei->{$wq_fld // 'wq1'}; + $lei->sto_done_request($wq); + $wq // $lei->fail; # already failed } sub watch_state_ok ($) { @@ -1498,16 +1508,18 @@ sub git_oid { } sub lms { - my ($lei, $rw) = @_; + my ($lei, $creat) = @_; my $sto = $lei->{sto} // _lei_store($lei) // return; require PublicInbox::LeiMailSync; my $f = "$sto->{priv_eidx}->{topdir}/mail_sync.sqlite3"; - (-f $f || $rw) ? PublicInbox::LeiMailSync->new($f) : undef; + (-f $f || $creat) ? PublicInbox::LeiMailSync->new($f) : undef; } sub sto_done_request { - my ($lei, $sock) = @_; + my ($lei, $wq) = @_; + return unless $lei->{sto}; local $current_lei = $lei; + my $sock = $wq ? $wq->{lei_sock} : undef; eval { if ($sock //= $lei->{sock}) { # issue, async wait $lei->{sto}->wq_io_do('done', [ $sock ]);