[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [snowflake/main] fix(client/snowflake.go): prevent wg.Add race condition



commit aefabe683f3fba846707a9f3a5e11f9b4be16990
Author: Simone Basso <bassosimone@xxxxxxxxx>
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()
 

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits