Fix data race issue with write buffer (#347)

This commit is contained in:
thedevop
2023-12-21 15:13:36 -08:00
committed by GitHub
parent 624dde0986
commit 4c682384c5

View File

@@ -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