Skip to content

Commit

Permalink
Fix data race issue with write buffer (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevop authored Dec 21, 2023
1 parent 624dde0 commit 4c68238
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,12 +598,7 @@ func (cl *Client) WritePacket(pk packets.Packet) error {

// there are more writes in the queue
if cl.Net.outbuf == nil {
if l := buf.Len(); l < cl.ops.options.ClientNetWriteBufferSize {
cl.Net.outbuf = buf
return int64(l), nil
}

return buf.WriteTo(cl.Net.Conn)
cl.Net.outbuf = new(bytes.Buffer)
}

n, _ = buf.WriteTo(cl.Net.outbuf) // will always be successful
Expand Down

0 comments on commit 4c68238

Please sign in to comment.