From a0541e3dc8a1a30367f2a011628df98e82ec418a Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 19:11:20 -1000 Subject: Give the cgit hold-lock runs a time limit hold-lock has to start cgit inside its hold, so it could not use cgit_rc, and a cgit that blocked on the held lock stalled the run for good instead of failing. The strace helper cannot use cgit_rc either, and now says so. --- tests/t0003-cache.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh index b1b0a2b..6a04411 100755 --- a/tests/t0003-cache.sh +++ b/tests/t0003-cache.sh @@ -30,13 +30,21 @@ test_lazy_prereq PERL_RUNS ' ' # Runs a command while holding the flock on the file named first, as another -# request at work on the same lock would. +# request at work on the same lock would. The command has to start inside the +# hold, which cgit_rc cannot do, so the alarm cgit_rc would set is set here, +# and a cgit that waits on the lock fails its test rather than stalling it. write_hold_lock() { write_script hold-lock "$PERL_PATH" <<-\EOF use Fcntl qw(:flock); open(my $lock, ">>", shift) or die "$!\n"; flock($lock, LOCK_EX | LOCK_NB) or die "$!\n"; - exit(system(@ARGV) ? 1 : 0); + defined(my $pid = fork) or die "$!\n"; + if (!$pid) { + alarm 60; + exec @ARGV or die "$ARGV[0]: $!\n"; + } + waitpid($pid, 0); + exit($? ? 1 : 0); EOF } @@ -498,7 +506,8 @@ test_lazy_prereq STRACE_DELAY ' ' # Returns once the trace shows the second request has opened the lock file, -# which the first request still holds. +# which the first request still holds. strace has to start cgit itself, so +# the request is set up here rather than by cgit_rc. start_traced_request() { rm -f second.trace strace -o second.trace -e trace=%file,flock \ -- cgit 2.12.1