Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Let the fd filter find the lock file itself
The test named the lock file through a variable set for cgit alone,
which kept it from going through cgit_rc, as a variable set ahead of a
shell function call does not portably reach the commands it runs. The
slot names fixed at 00000000 were never explained either.
| -rwxr-xr-x | tests/t0003-cache.sh | 13 |
1 file changed, 9 insertions, 4 deletions
diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh index 3bdbe3f..346ce86 100755 --- a/tests/t0003-cache.sh +++ b/tests/t0003-cache.sh @@ -453,6 +453,8 @@ overlap_requests() { # finding the lock held is ordinary contention, which logs nothing and gets # the page uncached. A network filesystem that fakes flock with record locks # breaks this the same way, so the trash directory has to be local. +# A config of one slot puts every page in 00000000, as the slot is named after +# the key's hash modulo cache-size. test_expect_success 'a slot stays locked while an exec filter runs' ' rm -rf cache3 && mkdir cache3 && write_script slow-filter.sh <<-EOF && @@ -544,13 +546,17 @@ 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. +# 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' ' 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 @lock = stat $ENV{LOCK_FILE} or die "$!\n"; + 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] @@ -563,8 +569,7 @@ test_expect_success PERL_RUNS 'a filter holds the lock file only as its stdout' echo "repo.readme=:file-1" && echo "repo.about-filter=exec:$PWD/fd-filter" } >fdrc && - LOCK_FILE="$PWD/cache3/00000000.lock" CGIT_CONFIG="$PWD/fdrc" \ - QUERY_STRING="url=bigpage/about/" cgit >fd.out && + cgit_rc fdrc "url=bigpage/about/" >fd.out && grep -F "lock file on fd 1." fd.out ' |
