]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
fake_inotify: increase directory ctime adjustment window
authorEric Wong <e@80x24.org>
Fri, 8 Sep 2023 12:54:12 +0000 (12:54 +0000)
committerEric Wong <e@80x24.org>
Fri, 8 Sep 2023 20:43:19 +0000 (20:43 +0000)
It actually needs to be bigger than the polling interval.
I suspect I missed this due to parallel tests on a loaded
VM, but running t/dir_idle.t on an unloaded machine reproduces
the problem when neither IO::KQueue nor Linux::Inotify2 are
present.

lib/PublicInbox/FakeInotify.pm
t/dir_idle.t

index 3a09b0309c9d033a4f5ff2cb8bac123db72fd152..8be0713563a952ce6b3c7be2a99806a1d2ef2168 100644 (file)
@@ -92,7 +92,8 @@ sub dir_adj ($) {
        my ($old_ctime) = @_;
        my $now = Time::HiRes::time;
        my $diff = $now - $old_ctime;
-       ($diff > -1 && $diff < 1) ? 1 : 0;
+       my $adj = $poll_intvl + 1;
+       ($diff > -$adj && $diff < $adj) ? 1 : 0;
 }
 
 # behaves like non-blocking Linux::Inotify2->read
index 9e66cc58731f4b3a29213fd177e16bb148900a33..bb6f47ebbaa514ac6ad34cf2b09b47a76681612d 100644 (file)
@@ -16,9 +16,11 @@ my $end = 3 + now;
 local @PublicInbox::DS::post_loop_do = (sub { scalar(@x) == 0 && now < $end });
 rmdir("$tmpdir/a/b") or xbail "rmdir $!";
 PublicInbox::DS::event_loop();
-is(scalar(@x), 1, 'got an rmdir event') and
+is(scalar(@x), 1, 'got an rmdir event') or xbail explain(\@x);
+if (@x) {
        is($x[0]->[0]->fullname, "$tmpdir/a/b", 'got expected fullname') and
        ok($x[0]->[0]->IN_DELETE, 'IN_DELETE set');
+}
 
 rmdir("$tmpdir/a") or xbail "rmdir $!";
 @x = ();