lib/PublicInbox/LEI.pm | 1 + lib/PublicInbox/LeiToMail.pm | 13 +++++++++++++ lib/PublicInbox/LeiXSearch.pm | 15 +++++++++------ diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 0d4b1c11ade60c2462b563df77b582f9a2df7407..24efb49489c39332eb3110025543b41a818121ba 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -739,6 +739,7 @@ send($sock, exec_buf(\@cmd, {}), MSG_EOR); } elsif ($self->{oneshot}) { $self->{"mua.pid.$self.$$"} = spawn(\@cmd); } + delete $self->{-progress}; } # caller needs to "-t $self->{1}" to check if tty diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm index f925086098518f3de4bc1cc22dc64d0fb3e91250..5a6f18fb4491205e003c763bee2b9fdc3e6bfd3a 100644 --- a/lib/PublicInbox/LeiToMail.pm +++ b/lib/PublicInbox/LeiToMail.pm @@ -365,6 +365,7 @@ $self->{base_type} = 'mbox'; } else { die "bad mail --format=$fmt\n"; } + $self->{dst} = $dst; $lei->{dedupe} = PublicInbox::LeiDedupe->new($lei); $self; } @@ -472,6 +473,18 @@ close $zpipe->[0]; } $self->{wcb} = $self->write_cb($lei); $self->SUPER::ipc_atfork_child; +} + +sub lock_free { + $_[0]->{base_type} =~ /\A(?:maildir|mh|imap|jmap)\z/ ? 1 : 0; +} + +sub poke_dst { + my ($self) = @_; + if ($self->{base_type} eq 'maildir') { + my $t = time + 1; + utime($t, $t, "$self->{dst}/cur"); + } } sub write_mail { # via ->wq_do diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index 0ca871ea8542e635bef78a65d387c2c9dfe0de45..e7f0ef6369e3d6fa400ad332a97314357c5e9ee9 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -308,13 +308,13 @@ } sub query_done { # EOF callback for main daemon my ($lei) = @_; - my $has_l2m = exists $lei->{l2m}; - for my $f (qw(lxs l2m)) { - my $wq = delete $lei->{$f} or next; - $wq->wq_wait_old($lei); + my $l2m = delete $lei->{l2m}; + $l2m->wq_wait_old($lei) if $l2m; + if (my $lxs = delete $lei->{lxs}) { + $lxs->wq_wait_old($lei); } $lei->{ovv}->ovv_end($lei); - if ($has_l2m) { # close() calls LeiToMail reap_compress + if ($l2m) { # close() calls LeiToMail reap_compress if (my $out = delete $lei->{old_1}) { if (my $mbout = $lei->{1}) { close($mbout) or return $lei->fail(<<""); @@ -323,7 +323,7 @@ } $lei->{1} = $out; } - $lei->start_mua; + $l2m->lock_free ? $l2m->poke_dst : $lei->start_mua; } $lei->{-progress} and $lei->err('# ', $lei->{-mset_total} // 0, " matches"); @@ -355,6 +355,9 @@ } sub start_query { # always runs in main (lei-daemon) process my ($self, $lei) = @_; + if (my $l2m = $lei->{l2m}) { + $lei->start_mua if $l2m->lock_free; + } if ($lei->{opt}->{thread}) { for my $ibxish (locals($self)) { $self->wq_do('query_thread_mset', [], $ibxish);