mirror of
https://github.com/git/git.git
synced 2026-06-24 08:48:31 +00:00
Merge branch 'ps/transport-helper-tsan-fix'
The TSAN race in transfer_debug() within transport-helper.c has been resolved by initializing the debug flag early in bidirectional_transfer_loop() before spawning worker threads, allowing the removal of a TSAN suppression. * ps/transport-helper-tsan-fix: transport-helper: fix TSAN race in transfer_debug()
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
# A static variable is written to racily, but we always write the same value, so
|
||||
# in practice it (hopefully!) doesn't matter.
|
||||
race:^want_color$
|
||||
race:^transfer_debug$
|
||||
|
||||
# A boolean value, which tells whether the replace_map has been initialized or
|
||||
# not, is read racily with an update. As this variable is written to only once,
|
||||
|
||||
@@ -1361,24 +1361,18 @@ int transport_helper_init(struct transport *transport, const char *name)
|
||||
/* This should be enough to hold debugging message. */
|
||||
#define PBUFFERSIZE 8192
|
||||
|
||||
static int transfer_debug_enabled = -1;
|
||||
|
||||
/* Print bidirectional transfer loop debug message. */
|
||||
__attribute__((format (printf, 1, 2)))
|
||||
static void transfer_debug(const char *fmt, ...)
|
||||
{
|
||||
/*
|
||||
* NEEDSWORK: This function is sometimes used from multiple threads, and
|
||||
* we end up using debug_enabled racily. That "should not matter" since
|
||||
* we always write the same value, but it's still wrong. This function
|
||||
* is listed in .tsan-suppressions for the time being.
|
||||
*/
|
||||
|
||||
va_list args;
|
||||
char msgbuf[PBUFFERSIZE];
|
||||
static int debug_enabled = -1;
|
||||
|
||||
if (debug_enabled < 0)
|
||||
debug_enabled = getenv("GIT_TRANSLOOP_DEBUG") ? 1 : 0;
|
||||
if (!debug_enabled)
|
||||
if (transfer_debug_enabled < 0)
|
||||
BUG("somebody forgot to check GIT_TRANSLOOP_DEBUG!");
|
||||
if (!transfer_debug_enabled)
|
||||
return;
|
||||
|
||||
va_start(args, fmt);
|
||||
@@ -1648,6 +1642,9 @@ int bidirectional_transfer_loop(int input, int output)
|
||||
{
|
||||
struct bidirectional_transfer_state state;
|
||||
|
||||
if (transfer_debug_enabled < 0)
|
||||
transfer_debug_enabled = getenv("GIT_TRANSLOOP_DEBUG") ? 1 : 0;
|
||||
|
||||
/* Fill the state fields. */
|
||||
state.ptg.src = input;
|
||||
state.ptg.dest = 1;
|
||||
|
||||
Reference in New Issue
Block a user