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

Re: [PATCH] lockfile.c: schedule remove_lock_file only once.

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 13, 2007, 18:23 UTC
Message-ID
<7vabu0noxg.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20070713141450.GA8392MdfPADPa@greensroom.kotnet.org>
Sven Verdoolaege <skimo@kotnet.org> writes:
> Removing a lockfile once should be enough.

Yeah. I wonder what we were smoking. 415e96c8 which introduces the atexit to index.c does:

    int hold_index_file_for_update(struct cache_file *cf, const char *path)
    {
           sprintf(cf->lockfile, "%s.lock", path);
           cf->next = cache_file_list;
           cache_file_list = cf;
           if (!cf->next) {
                   signal(SIGINT, remove_lock_file_on_signal);
                   atexit(remove_lock_file);
           }
           return open(cf->lockfile, O_RDWR | O_CREAT | O_EXCL, 0600);
    }
whose intent is exactly "do this once, only for the first one".

The reason we do not use lk->next but instead check lk->on_list, and the reason why we do not remove the lock from the list, are described in 1084b845.

But your "fire atexit() once" fix is needed.  Thanks.
Previous: Sven VerdoolaegeNext: Sven Verdoolaege
Message 2 of 3 in “lockfile.c: schedule remove_lock_file only once.”
  1. lockfile.c: schedule remove_lock_file only once.Sven Verdoolaege, Jul 13, 2007
  2. Junio C HamanoJul 13, 2007
  3. Sven VerdoolaegeJul 15, 2007

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.