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, 19:58 UTC
- Message-ID
- <xmqqldbltfrc.fsf@gitster.g>
- In-Reply-To
- <efd34c17157b3183cdc851c8b17e7967b6c85506.1783479584.git.gitgitgadget@gmail.com>
"Michael Montalbo via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 9 quoted lines
> From: Michael Montalbo <mmontalbo@gmail.com> > > http-429.sh records "already returned 429 once" with a "test -f" > followed by a "touch" of a shared state file. That check-then-act is not > atomic: Apache can run this CGI for several requests at once, and two of > them can both pass the "test -f" before either "touch"es, so both treat > themselves as the first request. The retry flow that drives this > endpoint is mostly sequential, so this has not been seen to fail, but > the race is latent.
OK. And use of mkdir for atomicity is an obvious solution for such a situtation.
Show 12 quoted lines
> -if test -f "$state_file" > +if test "$retry_after" != permanent && ! mkdir "$state" 2>/dev/null > then > # Already returned 429 once, forward to git-http-backend > # Set PATH_INFO to just the repo path (without retry-after value) > @@ -52,9 +55,6 @@ then > exec "$GIT_EXEC_PATH/git-http-backend" > fi > > -# Mark that we've returned 429 > -touch "$state_file" > -