From e324fdf46d4b37fb97a8d92a0b22364a0219b67a Mon Sep 17 00:00:00 2001 From: Michael Montalbo Date: Tue, 1 Sep 2026 00:27:56 +0000 Subject: [PATCH] t/lib-httpd: document writing concurrency-safe CGI helpers Update t/lib-httpd.sh to document the fixes applied to apply-one-time-script.sh and http-429.sh for future developers working on helper scripts. Add concrete examples of patterns and anti-patterns that should be considered when handling state management. Signed-off-by: Michael Montalbo Signed-off-by: Junio C Hamano --- t/lib-httpd.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index fc646447d5..9d422daccb 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -159,6 +159,17 @@ prepare_httpd() { mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH" cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH" cp "$TEST_PATH"/proxy-passwd "$HTTPD_ROOT_PATH" + # Apache can run the following scripts concurrently per request. Make + # sure any state management logic is resilient to race conditions. + # + # For example: + # - use "mkdir dir" to ensure only one request "succeeds" under some + # condition (see http-429.sh). + # - chain (&&) atomic operations like "rm marker" (no -f) with the + # logic that "claims" the marker instead of relying on a separate + # "test -f" and "rm marker" check (see apply-one-time-script.sh). + # - use scratch file names that include the process ID ($$), so + # concurrent requests do not overwrite each other's state. install_script incomplete-length-upload-pack-v2-http.sh install_script incomplete-body-upload-pack-v2-http.sh install_script error-no-report.sh