]> Sergey Matveev's repositories - public-inbox.git/commitdiff
xapcmd: delay over->check_inodes trigger
authorEric Wong <e@yhbt.net>
Sun, 5 Jul 2020 21:51:31 +0000 (21:51 +0000)
committerEric Wong <e@yhbt.net>
Tue, 14 Jul 2020 09:14:12 +0000 (09:14 +0000)
We must not trigger wakeups on InboxIdle users until after we've
renamed all files into place.  Otherwise, the InboxIdle caller
may just reopen the old (soon-to-be-unlinked) file.

This fixes occasional test failures in t/nntpd.t

Fixes: f977826a17f8735e ("lock: reduce inotify wakeups")
lib/PublicInbox/Xapcmd.pm

index 784140416e7fe5bb0ff3d0dfd86b24c28ba601da..a57fa5597030191a14e07e274104789e306fc50e 100644 (file)
@@ -23,6 +23,7 @@ sub commit_changes ($$$$) {
 
        $SIG{INT} or die 'BUG: $SIG{INT} not handled';
        my @old_shard;
+       my $over_chg;
 
        while (my ($old, $newdir) = each %$tmp) {
                next if $old eq ''; # no invalid paths
@@ -39,7 +40,7 @@ sub commit_changes ($$$$) {
                        my $tmp_over = "$new/over.sqlite3";
                        $over->connect->sqlite_backup_to_file($tmp_over);
                        $over = undef;
-                       syswrite($im->{lockfh}, '.'); # trigger ->check_inodes
+                       $over_chg = 1;
                }
 
                if (!defined($new)) { # culled shard
@@ -60,6 +61,10 @@ sub commit_changes ($$$$) {
                                die "failed to remove $prev: $!\n";
                }
        }
+
+       # trigger ->check_inodes in read-only daemons
+       syswrite($im->{lockfh}, '.') if $over_chg;
+
        remove_tree(@old_shard);
        $tmp = undef;
        if (!$opt->{-coarse_lock}) {