From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 793C61FFB1 for ; Thu, 4 Feb 2021 09:59:31 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 05/10] lei q: reinstate early MUA spawn for Maildir Date: Thu, 4 Feb 2021 00:59:25 -0900 Message-Id: <20210204095930.20278-6-e@80x24.org> In-Reply-To: <20210204095930.20278-1-e@80x24.org> References: <20210204095930.20278-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Once all files are written, we can use utime() to poke Maildirs to wake up MUAs that fail to account for nanosecond timestamps resolution. --- lib/PublicInbox/LEI.pm | 1 + lib/PublicInbox/LeiToMail.pm | 13 +++++++++++++ lib/PublicInbox/LeiXSearch.pm | 15 +++++++++------ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 0d4b1c11..24efb494 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -739,6 +739,7 @@ sub start_mua { } 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 f9250860..5a6f18fb 100644 --- a/lib/PublicInbox/LeiToMail.pm +++ b/lib/PublicInbox/LeiToMail.pm @@ -365,6 +365,7 @@ sub new { } else { die "bad mail --format=$fmt\n"; } + $self->{dst} = $dst; $lei->{dedupe} = PublicInbox::LeiDedupe->new($lei); $self; } @@ -474,6 +475,18 @@ sub ipc_atfork_child { $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 my ($self, $git_dir, $smsg) = @_; my $not_done = delete $self->{0} // die 'BUG: $not_done missing'; diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index 0ca871ea..e7f0ef63 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -308,13 +308,13 @@ sub git { 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 @@ Error closing $lei->{ovv}->{dst}: $! } $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 concurrency { 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);