fix: potential race conditions with non-local err

Some of the changes do not appear to have a potential race condition,
so there it is purely a refactor,
while in others (e.g. in broker.go and in proxy/lib/snowflake.go)
we do use the same variable from multiple threads / functions.
This commit is contained in:
WofWca 2025-03-02 15:24:39 +04:00
parent 01819eee32
commit 1923803124
5 changed files with 13 additions and 14 deletions

View file

@ -504,8 +504,7 @@ func (sf *SnowflakeProxy) makePeerConnectionFromOffer(
pw.Close()
})
dc.OnMessage(func(msg webrtc.DataChannelMessage) {
var n int
n, err = pw.Write(msg.Data)
n, err := pw.Write(msg.Data)
if err != nil {
if inErr := pw.CloseWithError(err); inErr != nil {
log.Printf("close with error generated an error: %v", inErr)