mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
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:
parent
01819eee32
commit
1923803124
5 changed files with 13 additions and 14 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue