Diff options
| -rwxr-xr-x | tests/t0003-cache.sh | 29 |
1 file changed, 17 insertions, 12 deletions
diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh index 346ce86..b1b0a2b 100755 --- a/tests/t0003-cache.sh +++ b/tests/t0003-cache.sh @@ -546,22 +546,26 @@ test_expect_success STRACE_DELAY 'a lock taken after the rename leaves the slot # An flock lasts until the last copy of its descriptor closes, so a filter # may hold the slot's lock file only as the stdout it writes the page to. A # stray copy would keep the slot locked for as long as the filter, or -# anything it leaves running, lives on. The filter finds the lock file from -# its own path, since a variable set for cgit_rc alone would not portably -# reach cgit. -test_expect_success PERL_RUNS 'a filter holds the lock file only as its stdout' ' +# anything it leaves running, lives on. The visitor's stdout, put aside while +# the fill has stdout, must not reach the filter at all, or one that outlives +# the request would hold the visitor's connection open. The filter finds both +# files from its own path, since a variable set for cgit_rc alone would not +# portably reach cgit. +test_expect_success PERL_RUNS 'a filter gets the lock file only as stdout and never the client' ' rm -rf cache3 && mkdir cache3 && write_script fd-filter "$PERL_PATH" <<-\EOF && use File::Basename qw(dirname); use POSIX qw(fstat); 1 while <STDIN>; - my $path = dirname($0) . "/cache3/00000000.lock"; - my @lock = stat $path or die "$path: $!\n"; - my @fds = grep { - my @fd = fstat($_); - @fd && $fd[0] == $lock[0] && $fd[1] == $lock[1] - } 0 .. 255; - print "lock file on fd @fds.\n"; + for my $file ("cache3/00000000.lock", "fd.out") { + my $path = dirname($0) . "/$file"; + my @file = stat $path or die "$path: $!\n"; + my @fds = grep { + my @fd = fstat($_); + @fd && $fd[0] == $file[0] && $fd[1] == $file[1] + } 0 .. 255; + print "$file on fd ", @fds ? "@fds" : "none", ".\n"; + } EOF { echo "cache-size=1" && @@ -570,7 +574,8 @@ test_expect_success PERL_RUNS 'a filter holds the lock file only as its stdout' echo "repo.about-filter=exec:$PWD/fd-filter" } >fdrc && cgit_rc fdrc "url=bigpage/about/" >fd.out && - grep -F "lock file on fd 1." fd.out + grep -F "cache3/00000000.lock on fd 1." fd.out && + grep -F "fd.out on fd none." fd.out ' # A refresh that cannot take the lock serves the expired copy, and says why |
