diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-10-08 00:45:12 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-10-08 00:45:12 +0000 |
commit | 89e1ae16f75923312bf487fd96ab74ce0211df73 (patch) | |
tree | 8b1a7c1b20231f33ac76361d3634b70b4c89d8d2 /pkg/tcpip/link/sharedmem/server_tx.go | |
parent | fd0024109aac305a161145ce219f936a0b61a0de (diff) | |
parent | e44b100654ca639d11221e547384f699e461296d (diff) |
Merge release-20210927.0-50-ge44b10065 (automated)
Diffstat (limited to 'pkg/tcpip/link/sharedmem/server_tx.go')
-rw-r--r-- | pkg/tcpip/link/sharedmem/server_tx.go | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/pkg/tcpip/link/sharedmem/server_tx.go b/pkg/tcpip/link/sharedmem/server_tx.go index 9370b2a46..13a82903f 100644 --- a/pkg/tcpip/link/sharedmem/server_tx.go +++ b/pkg/tcpip/link/sharedmem/server_tx.go @@ -20,6 +20,7 @@ package sharedmem import ( "golang.org/x/sys/unix" "gvisor.dev/gvisor/pkg/cleanup" + "gvisor.dev/gvisor/pkg/eventfd" "gvisor.dev/gvisor/pkg/tcpip/buffer" "gvisor.dev/gvisor/pkg/tcpip/link/sharedmem/pipe" "gvisor.dev/gvisor/pkg/tcpip/link/sharedmem/queue" @@ -40,7 +41,7 @@ type serverTx struct { data []byte // eventFD is used to notify the peer when fill requests are fulfilled. - eventFD int + eventFD eventfd.Eventfd // sharedData the memory region to use to enable/disable notifications. sharedData []byte @@ -80,16 +81,11 @@ func (s *serverTx) init(c *QueueConfig) error { // Duplicate the eventFD so that caller can close it but we can still // use it. - efd, err := unix.Dup(c.EventFD) + efd, err := c.EventFD.Dup() if err != nil { return err } - cu.Add(func() { unix.Close(efd) }) - - // Set the eventfd as non-blocking. - if err := unix.SetNonblock(efd, true); err != nil { - return err - } + cu.Add(func() { efd.Close() }) cu.Release() @@ -107,7 +103,7 @@ func (s *serverTx) cleanup() { unix.Munmap(s.completionPipe.Bytes()) unix.Munmap(s.data) unix.Munmap(s.sharedData) - unix.Close(s.eventFD) + s.eventFD.Close() } // fillPacket copies the data in the provided views into buffers pulled from the @@ -175,5 +171,5 @@ func (s *serverTx) transmit(views []buffer.View) bool { } func (s *serverTx) notify() { - unix.Write(s.eventFD, []byte{1, 0, 0, 0, 0, 0, 0, 0}) + s.eventFD.Notify() } |