Skip to content

Commit

Permalink
Do not call release_pack_memory in malloc wrappers when GIT_TRACE is …
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
j6t authored and gitster committed May 9, 2010
1 parent 851c34b commit 3a09425
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions trace.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3a09425

Please sign in to comment.