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

Re: [GSoC14][RFC] Proposal Draft: Refactor tempfile handling

From
Brian Gesiak <modocache@gmail.com>
Date
Mar 12, 2014, 12:26 UTC
Message-ID
<CAN7MxmXzowHjPFKS_+Dw8n8GUX7ooqTXW6MAGpNLA-VxnFY9uQ@mail.gmail.com>
In-Reply-To
<20140311180559.GB28154@sigill.intra.peff.net>
Show 5 quoted lines
> Currently the linked list of lockfiles only grows, never shrinks.  Once
> an object has been linked into the list, there is no way to remove it
> again even after the lock has been released.  So if a lock needs to be
> created dynamically at a random place in the code, its memory is
> unavoidably leaked.

Ah yes, I see. I think a good example is config.git_config_set_multivar_in_file, which even contains a comment detailing the problem: "Since lockfile.c keeps a linked list of all created lock_file structures, it isn't safe to free(lock). It's better to just leave it hanging around."

Show 5 quoted lines
> But I have a feeling that if we want to use a similar mechanism to
> handle all temporary files (of which there can be more), then it would
> be a good idea to lift this limitation.  It will require some care,
> though, to make sure that record removal is done in a way that is
> threadsafe and safe in the event of all expected kinds of process death.

It sounds like a threadsafe linked-list with an interface to manually remove elements from the list is the solution here; does that sound reasonable? Ensuring thread safety without sacrificing readability is probably more difficult than it sounds, but I don't think it's impossible.

I'll add some more details on this to my proposal[1]. Thank you!
- Brian Gesiak
[1] https://www.google-melange.com/gsoc/proposal/review/student/google/gsoc2014/modocache/5629499534213120
Previous: Jeff King
Message 7 of 7 in “[GSoC14][RFC] Proposal Draft: Refactor tempfile handling”
  1. Brian GesiakMar 1, 2014
  2. Jeff KingMar 3, 2014
  3. Brian GesiakMar 8, 2014
  4. Jeff KingMar 11, 2014
  5. Michael HaggertyMar 11, 2014
  6. Jeff KingMar 11, 2014
  7. Brian GesiakMar 12, 2014

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.