mirror of
https://github.com/mochi-mqtt/server.git
synced 2025-09-26 20:21:12 +08:00
Fix data race issue with write buffer (#347)
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user