git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 06/11] git-fetch: Release objects used by a prior transport
@ 2007-11-09 11:06 Shawn O. Pearce
  2007-11-09 22:27 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Shawn O. Pearce @ 2007-11-09 11:06 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Some transports allocate objects in the internal object hashtable
during the fetch process (e.g. the HTTP commit walker and also the
native protocol).  These shouldn't be visible to another transport
call running in the same fetch process when we fetch the tags during
automated tag following.  By deallocating the object table (if it
has anything in it) we ensure the second transport execution will
be from a clean slate.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 builtin-fetch.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

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);
-- 
1.5.3.5.1622.g41d10

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 06/11] git-fetch: Release objects used by a prior transport
  2007-11-09 11:06 [PATCH 06/11] git-fetch: Release objects used by a prior transport Shawn O. Pearce
@ 2007-11-09 22:27 ` Junio C Hamano
  2007-11-11  5:29   ` Shawn O. Pearce
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2007-11-09 22:27 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git

"Shawn O. Pearce" <spearce@spearce.org> writes:

> Some transports allocate objects in the internal object hashtable
> during the fetch process (e.g. the HTTP commit walker and also the
> native protocol).  These shouldn't be visible to another transport
> call running in the same fetch process when we fetch the tags during
> automated tag following.  By deallocating the object table (if it
> has anything in it) we ensure the second transport execution will
> be from a clean slate.
>
> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
> ---
>  builtin-fetch.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
>
> 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?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 06/11] git-fetch: Release objects used by a prior transport
  2007-11-09 22:27 ` Junio C Hamano
@ 2007-11-11  5:29   ` Shawn O. Pearce
  0 siblings, 0 replies; 3+ messages in thread
From: Shawn O. Pearce @ 2007-11-11  5:29 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano <gitster@pobox.com> wrote:
> "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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-11-11  5:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-09 11:06 [PATCH 06/11] git-fetch: Release objects used by a prior transport Shawn O. Pearce
2007-11-09 22:27 ` Junio C Hamano
2007-11-11  5:29   ` Shawn O. Pearce

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).