From 4c682384c53ce740cdb5bf096ee4b18f487e9475 Mon Sep 17 00:00:00 2001 From: thedevop <60499013+thedevop@users.noreply.github.com> Date: Thu, 21 Dec 2023 15:13:36 -0800 Subject: [PATCH] Fix data race issue with write buffer (#347) --- clients.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/clients.go b/clients.go index 9e9f9f4..877bd38 100644 --- a/clients.go +++ b/clients.go @@ -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