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

@ -144,7 +144,7 @@ func (enc *elementEncoder) Write(p []byte) (n int, err error) {
if enc.chunkCounter >= bytesPerChunk {
enc.chunkCounter = 0
enc.elementCounter += 1
nn, err = enc.w.Write([]byte("\n"))
nn, err := enc.w.Write([]byte("\n"))
if err != nil {
return total, err
}
@ -153,7 +153,7 @@ func (enc *elementEncoder) Write(p []byte) (n int, err error) {
if enc.elementCounter >= chunksPerElement {
enc.elementCounter = 0
nn, err = enc.w.Write([]byte("</pre>\n"))
nn, err := enc.w.Write([]byte("</pre>\n"))
if err != nil {
return total, err
}