git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] receive-pack: fix stale packfile locks when dying

From
Taylor Blau <me@ttaylorr.com>
Date
Mar 9, 2023, 18:26 UTC
Message-ID
<ZAokxsXGwgdNEmDc@nand.local>
In-Reply-To
<e16bd81bf9e251aa6959fbe10a3fbc215a4a1c12.1678367338.git.ps@pks.im>
On Thu, Mar 09, 2023 at 02:09:23PM +0100, Patrick Steinhardt wrote:
> Fix this race by installing an atexit(3P) handler that unlinks the keep
> file.

This reminded me of a discussion that I thought you and I had a few months ago on the list about whether or not it was safe to call unlink() in an async signal handler.

TL;DR, it is, and the link back to that discussion is here:
  https://lore.kernel.org/git/YdjBkZsnYd+zYne1@nand.local/
Show 19 quoted lines
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  builtin/receive-pack.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
> index cd5c7a28ef..0a6030d775 100644
> --- a/builtin/receive-pack.c
> +++ b/builtin/receive-pack.c
> @@ -2186,6 +2186,12 @@ static const char *parse_pack_header(struct pack_header *hdr)
>
>  static const char *pack_lockfile;
>
> +static void unlink_pack_lockfile(void)
> +{
> +	if (pack_lockfile)
> +		unlink(pack_lockfile);
> +}
> +

...and I think that this would all work, but I agree that using the tempfile API here (as Peff suggests below) would probably be more ergonomic.

Thanks, Taylor

Previous: Jeff KingNext: Junio C Hamano
Message 5 of 11 in “receive-pack: fix stale packfile locks when dying”
  1. receive-pack: fix stale packfile locks when dyingPatrick Steinhardt, Mar 9, 2023
  2. Jeff KingMar 9, 2023
  3. Patrick SteinhardtMar 10, 2023
  4. Jeff KingMar 10, 2023
  5. Taylor BlauMar 9, 2023
  6. Junio C HamanoMar 9, 2023
  7. Junio C HamanoMar 9, 2023
  8. receive-pack: fix stale packfile locks when dyingPatrick Steinhardt, Mar 10, 2023
  9. Jeff KingMar 10, 2023
  10. Patrick SteinhardtMar 10, 2023
  11. Jeff KingMar 10, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.