Hi,
As i understand,  WriteTo is used to optimize write of multiple buffers
to socket, using writev. But writev also ensure that these multiple
buffers are written atomically, in case of concurrent writes, bytes
from concurrent write are not inserted between buffers of writev.

https://cs.opensource.google/go/go/+/refs/tags/go1.23.4:src/net/net.go;l=841

As can i see, in general case (when io.Writer does not implement
buffersWriter), buffers are written by ranging over them and  using
Write, which does not ensure atomic write of all buffers.
I think proper implementation should consolidate all buffers in 1
buffer (yes, allocate memory), and write this one with Write.

Does i miss something ?
Is current implementation are correct ?

-- 
Jamil Djadala

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/20250115140610.2e324e04%40beast.

Reply via email to