[tor-commits] [snowflake/main] fix(client/snowflake.go): prevent wg.Add race condition
cohosh at torproject.org
cohosh at torproject.org
Mon Jun 14 13:46:47 UTC 2021
commit aefabe683f3fba846707a9f3a5e11f9b4be16990
Author: Simone Basso <bassosimone at gmail.com>
Date: Mon May 3 10:23:03 2021 +0200
fix(client/snowflake.go): prevent wg.Add race condition
In VSCode, the staticcheck tool emits this warning:
> should call wg.Add(1) before starting the goroutine to
> avoid a race (SA2000)go-staticcheck
To avoid this warning, just move wg.Add outside.
---
client/snowflake.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/snowflake.go b/client/snowflake.go
index bacc389..af9c2e4 100644
--- a/client/snowflake.go
+++ b/client/snowflake.go
@@ -56,8 +56,8 @@ func socksAcceptLoop(ln *pt.SocksListener, transport *sf.Transport, shutdown cha
break
}
log.Printf("SOCKS accepted: %v", conn.Req)
+ wg.Add(1)
go func() {
- wg.Add(1)
defer wg.Done()
defer conn.Close()
More information about the tor-commits
mailing list