[PATCH 2/2] Do not call release_pack_memory in malloc wrappers when GIT_TRACE is used

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Johannes Sixt
Date: Saturday, May 8, 2010 - 8:18 am

This avoids a potential race condition when async procedures are
implemented as threads where release_pack_memory() can be called from
different threads without locking under memory pressure.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 It is worthwhile to have this in np/malloc-threading (and in maint or
 master) even if js/async-thread is not in master, yet, because on
 Windows we already have async procedures implemented in threads.

 trace.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/trace.c b/trace.c
index 4229ae1..1e560cb 100644
--- a/trace.c
+++ b/trace.c
@@ -25,6 +25,10 @@
 #include "cache.h"
 #include "quote.h"
 
+void do_nothing(size_t unused)
+{
+}
+
 /* Get a trace file descriptor from GIT_TRACE env variable. */
 static int get_trace_fd(int *need_close)
 {
@@ -72,6 +76,7 @@ void trace_printf(const char *fmt, ...)
 	if (!fd)
 		return;
 
+	set_try_to_free_routine(do_nothing);	/* is never reset */
 	strbuf_init(&buf, 64);
 	va_start(ap, fmt);
 	len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap);
@@ -103,6 +108,7 @@ void trace_argv_printf(const char **argv, const char *fmt, ...)
 	if (!fd)
 		return;
 
+	set_try_to_free_routine(do_nothing);	/* is never reset */
 	strbuf_init(&buf, 64);
 	va_start(ap, fmt);
 	len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap);
-- 
1.7.1.64.ga1799.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
What's cooking in git.git (May 2010, #01; Sun, 2), Junio C Hamano, (Sun May 2, 9:12 am)
Re: What's cooking in git.git (May 2010, #01; Sun, 2), Johannes Sixt, (Sun May 2, 1:01 pm)
Re: What's cooking in git.git (May 2010, #01; Sun, 2), Jakub Narebski, (Mon May 3, 5:48 am)
Re: What's cooking in git.git (May 2010, #01; Sun, 2), Will Palmer, (Mon May 3, 11:54 am)
Re: jn/shortlog, Jonathan Nieder, (Mon May 3, 6:56 pm)
[PATCH v2 0/5] jn/shortlog, Jonathan Nieder, (Mon May 3, 7:52 pm)
[PATCH 4/5] shortlog: Document and test --format option, Jonathan Nieder, (Mon May 3, 7:59 pm)
[PATCH 5/5] pretty: Respect --abbrev option, Jonathan Nieder, (Mon May 3, 8:18 pm)
Re: [PATCH 5/5] pretty: Respect --abbrev option, Jonathan Nieder, (Tue May 4, 1:34 am)
[PATCH 2/2] Do not call release_pack_memory in malloc wrap ..., Johannes Sixt, (Sat May 8, 8:18 am)
Re: What's cooking in git.git (May 2010, #01; Sun, 2), Clemens Buchacher, (Sat May 8, 9:43 am)