diff options
author | Eric Wong <e@80x24.org> | 2021-02-04 00:59:25 -0900 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-02-05 00:16:30 +0000 |
commit | a54a442b9a125f93518b8e50411403a708f8fc2e (patch) | |
tree | 98f68a23582619ab70fdcfac3d731ee323a46f9e /lib | |
parent | 52e864b5e7e45eafe559a28bad70b2f23fad7bf9 (diff) | |
download | public-inbox-a54a442b9a125f93518b8e50411403a708f8fc2e.tar.gz |
Once all files are written, we can use utime() to poke Maildirs to wake up MUAs that fail to account for nanosecond timestamps resolution.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/LEI.pm | 1 | ||||
-rw-r--r-- | lib/PublicInbox/LeiToMail.pm | 13 | ||||
-rw-r--r-- | 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); |