Re: [PATCH v3 3/3] t/lib-httpd: document writing concurrency-safe CGI helpers
On Thu, Aug 13, 2026 at 01:05:36AM +0000, Michael Montalbo via GitGitGadget wrote:
Show 20 quoted lines
> diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
> index fc646447d5..f26e1594ab 100644
> --- a/t/lib-httpd.sh
> +++ b/t/lib-httpd.sh
> @@ -159,6 +159,19 @@ prepare_httpd() {
> mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH"
> cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH"
> cp "$TEST_PATH"/proxy-passwd "$HTTPD_ROOT_PATH"
> + # Apache runs each of these CGI scripts once per request. Apache can run one
> + # script for several requests at the same time. A helper that keeps state
> + # between requests must update that state with one atomic operation. A check
> + # and then a separate action is not safe: two requests can both pass the
> + # check before either one acts. Test the exit status of one atomic operation
> + # instead:
> + # - "mkdir dir" fails if the directory exists, so only one request
> + # succeeds. http-429.sh selects the first request this way.
> + # - "rm marker" (without "-f") fails if the marker is gone, so only one
> + # request consumes it. apply-one-time-script.sh claims its one-shot
> + # marker this way.
> + # A scratch file name includes the process ID ($$), so concurrent requestsNit, not worth rerolling over: s/includes/should include/
Patrick