mirror of
https://github.com/mochi-mqtt/server.git
synced 2025-10-04 07:46:34 +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
|
// there are more writes in the queue
|
||||||
if cl.Net.outbuf == nil {
|
if cl.Net.outbuf == nil {
|
||||||
if l := buf.Len(); l < cl.ops.options.ClientNetWriteBufferSize {
|
cl.Net.outbuf = new(bytes.Buffer)
|
||||||
cl.Net.outbuf = buf
|
|
||||||
return int64(l), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf.WriteTo(cl.Net.Conn)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
n, _ = buf.WriteTo(cl.Net.outbuf) // will always be successful
|
n, _ = buf.WriteTo(cl.Net.outbuf) // will always be successful
|
||||||
|
Reference in New Issue
Block a user