From: Eric Wong Date: Fri, 8 Sep 2023 12:54:12 +0000 (+0000) Subject: fake_inotify: increase directory ctime adjustment window X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a0f5c42a8e22a01c076ef38204d3ee9fa8b3af2;p=thirdparty%2Fpublic-inbox.git fake_inotify: increase directory ctime adjustment window 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. --- diff --git a/lib/PublicInbox/FakeInotify.pm b/lib/PublicInbox/FakeInotify.pm index 3a09b0309..8be071356 100644 --- a/lib/PublicInbox/FakeInotify.pm +++ b/lib/PublicInbox/FakeInotify.pm @@ -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 diff --git a/t/dir_idle.t b/t/dir_idle.t index 9e66cc587..bb6f47ebb 100644 --- a/t/dir_idle.t +++ b/t/dir_idle.t @@ -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 = ();