From: Junio C Hamano Date: Wed, 08 Jul 2026 19:58:47 GMT Subject: Re: [PATCH 2/3] t/lib-httpd: make http-429 first-request check atomic Message-ID: In-Reply-To: "Michael Montalbo via GitGitGadget" writes: > From: Michael Montalbo > > 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. > -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" > -