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

Re: [PATCH 06/11] git-fetch: Release objects used by a prior transport

From
Shawn O. Pearce <spearce@spearce.org>
Date
Nov 11, 2007, 05:29 UTC
Message-ID
<20071111052949.GU14735@spearce.org>
In-Reply-To
<7vve8bqcke.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> wrote:
Show 23 quoted lines
> "Shawn O. Pearce" <spearce@spearce.org> writes:
> > diff --git a/builtin-fetch.c b/builtin-fetch.c
> > index 847db73..18f123e 100644
> > --- a/builtin-fetch.c
> > +++ b/builtin-fetch.c
> > @@ -337,7 +337,10 @@ static void store_updated_refs(const char *url, struct ref *ref_map)
> >  
> >  static int fetch_refs(struct transport *transport, struct ref *ref_map)
> >  {
> > -	int ret = transport_fetch_refs(transport, ref_map);
> > +	int ret;
> > +
> > +	free_all_objects();
> > +	ret = transport_fetch_refs(transport, ref_map);
> >  	if (!ret)
> >  		store_updated_refs(transport->url, ref_map);
> >  	transport_unlock_pack(transport);
> 
> This sounds a very heavy-handed approach.
> 
> Is it the callers responsibility to know what function does call
> free_all_objects() and makes sure there is no pointer to objects
> obtained before the call that is used after the call returns?

Yea, I guess it is. That's part of the reason why this usage was put here in a static function of builtin-fetch. Its high enough up in the call stack that nobody above it cares. Where we would run into trouble would be if a transport decided to hang onto any pointers in its data structure between calls to the transport.

Lets just say we don't free the objects; the flags are still all messed up from any prior user. Its tricky to reuse the objects because we don't know what state an object is left in by someone that ran before us (e.g. an internal call to fetch-pack!). Its also tricky when they free the parent list but leave parsed=1; we can't rebuild the parent pointers!

-- 
Shawn.
Previous: Junio C Hamano
Message 3 of 3 in “git-fetch: Release objects used by a prior transport”
  1. 06/11 git-fetch: Release objects used by a prior transportShawn O. Pearce, Nov 9, 2007
  2. Junio C HamanoNov 9, 2007
  3. Shawn O. PearceNov 11, 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.