diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-02-18 01:45:49 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-02-18 01:45:49 +0000 |
commit | 2d9dc3c1b7be34442f224a10013dd5f3823c962a (patch) | |
tree | e25228b2da4ae13353eb247d3771352a182fb41e /pkg/fdchannel | |
parent | 45be62df210badd412752214925e0de28887ed54 (diff) | |
parent | f051ec64639b83faabcfe766ff078072def3c2aa (diff) |
Merge release-20210208.0-64-gf051ec646 (automated)
Diffstat (limited to 'pkg/fdchannel')
-rw-r--r-- | pkg/fdchannel/fdchannel_unsafe.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/pkg/fdchannel/fdchannel_unsafe.go b/pkg/fdchannel/fdchannel_unsafe.go index b253a8fdd..0ebdedf26 100644 --- a/pkg/fdchannel/fdchannel_unsafe.go +++ b/pkg/fdchannel/fdchannel_unsafe.go @@ -20,9 +20,10 @@ package fdchannel import ( "fmt" - "reflect" "syscall" "unsafe" + + "gvisor.dev/gvisor/pkg/gohacks" ) // int32 is the real type of a file descriptor. @@ -53,10 +54,10 @@ func (ep *Endpoint) Init(sockfd int) { // sendmsg+recvmsg for a zero-length datagram is slightly faster than // sendmsg+recvmsg for a single byte over a stream socket. cmsgSlice := make([]byte, syscall.CmsgSpace(sizeofInt32)) - cmsgReflect := (*reflect.SliceHeader)(unsafe.Pointer(&cmsgSlice)) + cmsgSliceHdr := (*gohacks.SliceHeader)(unsafe.Pointer(&cmsgSlice)) ep.sockfd = int32(sockfd) - ep.msghdr.Control = (*byte)(unsafe.Pointer(cmsgReflect.Data)) - ep.cmsg = (*syscall.Cmsghdr)(unsafe.Pointer(cmsgReflect.Data)) + ep.msghdr.Control = (*byte)(cmsgSliceHdr.Data) + ep.cmsg = (*syscall.Cmsghdr)(cmsgSliceHdr.Data) // ep.msghdr.Controllen and ep.cmsg.* are mutated by recvmsg(2), so they're // set before calling sendmsg/recvmsg. } |