Re: [PATCH 2/3] t/lib-httpd: make http-429 first-request check atomic
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 8, 2026, 20:02 UTC
- Message-ID
- <xmqqcxwxtfkp.fsf@gitster.g>
- In-Reply-To
- <efd34c17157b3183cdc851c8b17e7967b6c85506.1783479584.git.gitgitgadget@gmail.com>
"Michael Montalbo via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 7 quoted lines
> -# Check if this is the first call (no state file exists) > -if test -f "$state_file" > +# Apache can run this CGI for concurrent requests, so the script decides > +# whether this is the first call with a single atomic "mkdir": it succeeds for > +# exactly one of any racing requests and fails for the rest. "permanent" > +# always rate-limits and records no state. > +if test "$retry_after" != permanent && ! mkdir "$state" 2>/dev/null
I think the last sentence in the above comment was meant to explain why the new code checks the value of "$retry_after", but it is not clear if it is needed for correctness (in other words, the original was wrong to do "test -f && touch" but also was wrong to do so even when "$retry_after" is set to "permanent), or if it is a mere "optimization opportunity" you are taking advantage of. In either case, it would be nice to see it explained in the proposed commit log message.
Thanks.