From: Patrick Steinhardt Date: Mon, 31 Aug 2026 07:18:17 GMT Subject: Re: [PATCH v3 3/3] t/lib-httpd: document writing concurrency-safe CGI helpers Message-ID: In-Reply-To: <374d148f43036077c31c5a55ddb1b59da4d3a923.1786583137.git.gitgitgadget@gmail.com> On Thu, Aug 13, 2026 at 01:05:36AM +0000, Michael Montalbo via GitGitGadget wrote: > 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 requests Nit, not worth rerolling over: s/includes/should include/ Patrick