]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei q: reinstate early MUA spawn for Maildir
authorEric Wong <e@80x24.org>
Thu, 4 Feb 2021 09:59:25 +0000 (00:59 -0900)
committerEric Wong <e@80x24.org>
Fri, 5 Feb 2021 00:16:30 +0000 (00:16 +0000)
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
lib/PublicInbox/LeiToMail.pm
lib/PublicInbox/LeiXSearch.pm

index 0d4b1c11ade60c2462b563df77b582f9a2df7407..24efb49489c39332eb3110025543b41a818121ba 100644 (file)
@@ -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
index f925086098518f3de4bc1cc22dc64d0fb3e91250..5a6f18fb4491205e003c763bee2b9fdc3e6bfd3a 100644 (file)
@@ -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';
index 0ca871ea8542e635bef78a65d387c2c9dfe0de45..e7f0ef6369e3d6fa400ad332a97314357c5e9ee9 100644 (file)
@@ -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);