@matheusbsbs / matheus-bagliano / commits / 3a0942598c
Fork 0

Do not call release_pack_memory in malloc wrappers when GIT_TRACE is used

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Sixt committed May 8, 2010 at 17:18 UTC 3a0942598ce33b195bfaaf250b2da23e4eceb3c6
1 file changed +6
trace.c
+6
@@ -25,6 +25,10 @@
25 #include "cache.h"
26 #include "quote.h"
27
28 +void do_nothing(size_t unused)
29 +{
30 +}
31 +
32 /* Get a trace file descriptor from GIT_TRACE env variable. */
33 static int get_trace_fd(int *need_close)
34 {
@@ -72,6 +76,7 @@ void trace_printf(const char *fmt, ...)
76 if (!fd)
77 return;
78
79 + set_try_to_free_routine(do_nothing); /* is never reset */
80 strbuf_init(&buf, 64);
81 va_start(ap, fmt);
82 len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap);
@@ -103,6 +108,7 @@ void trace_argv_printf(const char **argv, const char *fmt, ...)
108 if (!fd)
109 return;
110
111 + set_try_to_free_routine(do_nothing); /* is never reset */
112 strbuf_init(&buf, 64);
113 va_start(ap, fmt);
114 len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap);