Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: golang/net
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: jdeisenh/net
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Jul 28, 2020

  1. Copy the full SHA
    415bc55 View commit details
Showing with 15 additions and 2 deletions.
  1. +15 −2 internal/socket/mmsghdr_unix.go
17 changes: 15 additions & 2 deletions internal/socket/mmsghdr_unix.go
Original file line number Diff line number Diff line change
@@ -11,16 +11,29 @@ import "net"
type mmsghdrs []mmsghdr

func (hs mmsghdrs) pack(ms []Message, parseFn func([]byte, string) (net.Addr, error), marshalFn func(net.Addr) []byte) error {
// Do one buffer allocation for the whole run
totalbuffers := 0
for i := range hs {
vs := make([]iovec, len(ms[i].Buffers))
totalbuffers += len(ms[i].Buffers)
}
vsa := make([]iovec, totalbuffers)
bufferOffset := 0
var saa []byte
if parseFn != nil {
saa = make([]byte, sizeofSockaddrInet6*len(hs))
}
for i := range hs {
numBufs := len(ms[i].Buffers)
vs := vsa[bufferOffset : bufferOffset+numBufs]
var sa []byte
if parseFn != nil {
sa = make([]byte, sizeofSockaddrInet6)
sa = saa[i*sizeofSockaddrInet6 : (i+1)*sizeofSockaddrInet6]
}
if marshalFn != nil {
sa = marshalFn(ms[i].Addr)
}
hs[i].Hdr.pack(vs, ms[i].Buffers, ms[i].OOB, sa)
bufferOffset += numBufs
}
return nil
}