mirror of
https://github.com/slackhq/nebula.git
synced 2026-05-16 04:47:38 +02:00
GSO again
This commit is contained in:
@@ -52,3 +52,35 @@ func (u *StdConn) PrepareRawMessages(n int) ([]rawMessage, [][]byte, [][]byte) {
|
||||
|
||||
return msgs, buffers, names
|
||||
}
|
||||
|
||||
// prepareWriteMessages allocates one Mmsghdr/iovec/sockaddr scratch per slot,
|
||||
// wired up so each writeMsgs[i] already points at writeIovs[i] and
|
||||
// writeNames[i]. Callers fill in the iovec Base/Len, the sockaddr bytes, and
|
||||
// Namelen before each sendmmsg.
|
||||
func (u *StdConn) prepareWriteMessages(n int) {
|
||||
u.writeMsgs = make([]rawMessage, n)
|
||||
u.writeIovs = make([]iovec, n)
|
||||
u.writeNames = make([][]byte, n)
|
||||
for i := range u.writeMsgs {
|
||||
u.writeNames[i] = make([]byte, unix.SizeofSockaddrInet6)
|
||||
u.writeMsgs[i].Hdr.Iov = &u.writeIovs[i]
|
||||
u.writeMsgs[i].Hdr.Iovlen = 1
|
||||
u.writeMsgs[i].Hdr.Name = &u.writeNames[i][0]
|
||||
}
|
||||
}
|
||||
|
||||
func setIovLen(v *iovec, n int) {
|
||||
v.Len = uint32(n)
|
||||
}
|
||||
|
||||
func setMsgIovlen(m *msghdr, n int) {
|
||||
m.Iovlen = uint32(n)
|
||||
}
|
||||
|
||||
func setMsgControllen(m *msghdr, n int) {
|
||||
m.Controllen = uint32(n)
|
||||
}
|
||||
|
||||
func setCmsgLen(h *unix.Cmsghdr, n int) {
|
||||
h.Len = uint32(n)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user