From a353fbd3b4475d06fd6fe3b7a5b8c47b4e5420ab Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 9 Sep 2021 11:35:04 -0700 Subject: [PATCH] tstest: make MemLogger.String acquire its mutex Updates #2781 (might even fix it, but its real issue is that SetPrivateKey starts a ReSTUN goroutines which then logs, and that bug and data race existed prior to MemLogger existing) --- tstest/log.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tstest/log.go b/tstest/log.go index c28199c63..f27d32906 100644 --- a/tstest/log.go +++ b/tstest/log.go @@ -139,3 +139,9 @@ func (ml *MemLogger) Logf(format string, args ...interface{}) { ml.Buffer.WriteByte('\n') } } + +func (ml *MemLogger) String() string { + ml.Lock() + defer ml.Unlock() + return ml.Buffer.String() +}